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