I want to change the default behavior of my submit button in simple_form so that I needn't explicitly specify :disable_with => true for all my forms. How can I make this particular change in the simple_form.rb?
This is a little different in newer versions of Rails, as setting the property disable_with is deprecated. I wrote an article on this: http://www.railsonmaui.com/blog/2014/02/23/simple-form-and-disable-processing-by-default/
Here's the new code:
SimpleForm::FormBuilder.class_eval do
def submit_with_override(field, options = {})
data_disable_with = { disable_with: 'Processing...' }
options[:data] = data_disable_with.merge(options[:data] || {})
submit_without_override(field, options)
end
alias_method_chain :submit, :override
end
And thanks to @Appster for the idea!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With