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 

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