Module: ActionValidator::FormHelper
- Defined in:
- app/helpers/action_validator/form_helper.rb
Overview
Form helpers that will render a standard Rails ‘form_for` or `form_with` that has all of the necessary attributes added for the ActionValidator Stimulus controller to work.
Instance Method Summary collapse
-
#validator_error(attribute, options = {}) ⇒ Object
Renders an unstyled div with the correct Stimulus data attributes on it.
-
#validator_form_for(record, options = {}, &block) ⇒ Object
A wrapper around the Rails form_for helper.
-
#validator_form_with(model: false, scope: nil, url: nil, format: nil, **options, &block) ⇒ Object
A wrapper around the Rails form_with helper.
Instance Method Details
#validator_error(attribute, options = {}) ⇒ Object
Renders an unstyled div with the correct Stimulus data attributes on it.
27 28 29 30 31 32 33 |
# File 'app/helpers/action_validator/form_helper.rb', line 27 def validator_error(attribute, = {}) [:data] ||= {} [:data][ActionValidator::STIMULUS_SELECTORS[:target]] = :error [:data][:attribute] = attribute tag.div(id: attribute, **) end |
#validator_form_for(record, options = {}, &block) ⇒ Object
A wrapper around the Rails form_for helper. This method can be used exactly the same as the standard Rails helper.
10 11 12 13 14 |
# File 'app/helpers/action_validator/form_helper.rb', line 10 def validator_form_for(record, = {}, &block) () form_for(record, , &block) end |
#validator_form_with(model: false, scope: nil, url: nil, format: nil, **options, &block) ⇒ Object
A wrapper around the Rails form_with helper. This method can be used exactly the same as the standard Rails helper.
19 20 21 22 23 |
# File 'app/helpers/action_validator/form_helper.rb', line 19 def validator_form_with(model: false, scope: nil, url: nil, format: nil, **, &block) () form_with(model: model, scope: scope, url: url, format: format, **, &block) end |