Module: ClientSideValidations::ActionView::Helpers::FormHelper
- Defined in:
- lib/client_side_validations/action_view/form_helper.rb
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
- #apply_form_for_options!(record, object, options) ⇒ Object
- #fields_for(record_name, record_object = nil, options = {}, &block) ⇒ Object
- #form_for(record, options = {}, &block) ⇒ Object
Instance Method Details
#apply_form_for_options!(record, object, options) ⇒ Object
39 40 41 42 |
# File 'lib/client_side_validations/action_view/form_helper.rb', line 39 def (record, object, ) super [:html][:validate] = true if [:validate] end |
#fields_for(record_name, record_object = nil, options = {}, &block) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/client_side_validations/action_view/form_helper.rb', line 44 def fields_for(record_name, record_object = nil, = {}, &block) # Order matters here. Rails mutates the `options` object output = super build_bound_validators! output end |
#form_for(record, options = {}, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/client_side_validations/action_view/form_helper.rb', line 10 def form_for(record, = {}, &block) return super unless [:validate] # We are not going to use super here, because we need # to inject the csv options in a data attribute in a clean way. # So we basically reimplement the whole form_for method raise ArgumentError, 'Missing block' unless block_given? = [:html] ||= {} # Moving the switch statement to another method to # lower complexity object, object_name = check_record(record, ) @validators = {} , builder = instantiate_builder(object_name, object, ) output = capture(builder, &block) [:multipart] ||= builder.multipart? build_bound_validators! , , builder = ([:url] || {}, ) form_tag_with_body(, output) end |