Make SimpleForm Inputs Disabled By Default In Rails

Posted by Weston Ganger on February 27, 2016

I needed to be able to set a default value for disabled based on a conditional in simple_form

Turns out they have a defaults hash that you can add this stuff. Super awesome!

simple_form_for @foo, defaults: { disabled: (true unless current_user.is_admin?) }

This is much better than setting each input individually or trying to do it through javascript unnecessarily.

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