Rails

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 


Want me to help develop your next project or application?

Contact Us

Specializing in Ruby-on-Rails, Javascript, Multi-Platform Electron Desktop Apps and Hybrid Cordova Mobile Apps.

Recommended Posts