Set Certain Select Options As Disabled Using Simple Form

Posted by Weston Ganger on March 19, 2016

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:

Posted in Rails and Tagged with simple_form rails forms 

Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts