Make SimpleForm Inputs Disabled By Default In Rails

Posted By Weston Ganger

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:

Article Topic:Software Development - Ruby / Rails

Date:February 27, 2016