Set Certain Select Options As Disabled Using Simple Form

Posted by Weston Ganger

I needed to disable a bunch of select options on my select box in my simple_form_for

Simple form has an easy way to do this:


= f.association :countries, collection: ['Canada','USA','Mexico','Russia'], disabled: ['Russia','Mexico'] 

Now all of the options will still show in the list but only Canada and USA will be selectable.


Related External Links:

Article Topic:Software Development - Rails

Date:March 19, 2016

Recommended Posts

Contact

604-309-8713
info@solidfoundationwebdev.com

Send Me A Message

I would love to get in touch and talk about your next project. Feel free to send a message and I will get back to you shortly.

Get Connected