Closed dmix closed 4 months ago
Might I suggest overriding the simple_form_for
helper and delegating to super
instead of looking for a configuration? e.g. something like this on your app helper:
module ApplicationHelper
def simple_form_for(record, options = {}, &block)
options[:html] ||= {}
options[:html][:"data-x"] ||= "zomg-it-works"
super
end
end
Alternatively, a custom form builder could work as well, but that might require changing simple_form_for
calls across your views so maybe not something to start with.
I'm trying to add a Stimulus handler to all forms:
I looked at the code in simple_form and the only option I see is to add a
default_form_class
:https://github.com/heartcombo/simple_form/blob/main/lib/simple_form/action_view_extensions/form_helper.rb
Is there a way to append a data attribute to every form without having to pass a custom data attribute to each one?
I tried appending it to wrapper_html on the default wrapper but it didnt work