Module: ClientSideValidations::ActionView::Helpers::FormHelper
- Defined in:
- lib/client_side_validations/action_view/form_helper.rb,
lib/client_side_validations/action_view/form_with_helper.rb
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
- #apply_csv_form_for_options!(record, object, options) ⇒ Object
- #fields_for(record_name, record_object = nil, options = {}, &block) ⇒ Object
- #form_for(record, options = {}, &block) ⇒ Object
- #form_with(model: nil, scope: nil, url: nil, format: nil, **options, &block) ⇒ Object
Instance Method Details
#apply_csv_form_for_options!(record, object, options) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/client_side_validations/action_view/form_helper.rb', line 39 def (record, object, ) [:html][:validate] = true if [:validate] [:html][:method] ||= [:method] # TODO: remove else branch when minimum compatible version when dropping 6.1 support if method(:apply_form_for_options!).arity == 2 object, else record, object, end end |
#fields_for(record_name, record_object = nil, options = {}, &block) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/client_side_validations/action_view/form_helper.rb', line 51 def fields_for(record_name, record_object = nil, = {}, &block) # Order matters here. Rails mutates the `options` object builder = instantiate_builder(record_name, record_object, ) output = capture(builder, &block) 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 [:html] ||= {} # Moving the switch statement to another method to # lower complexity model, object_name = check_record(record, ) remote = .delete(:remote) if remote && ! && [:authenticity_token].blank? [:authenticity_token] = false end [:model] = model [:scope] = object_name [:local] = !remote [:skip_default_ids] = false [:allow_method_names_outside_object] = .fetch(:allow_method_names_outside_object, false) form_with(**, &block) end |
#form_with(model: nil, scope: nil, url: nil, format: nil, **options, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/client_side_validations/action_view/form_with_helper.rb', line 7 def form_with(model: nil, scope: nil, url: nil, format: nil, **, &block) return super unless [:validate] [:allow_method_names_outside_object] = true [:skip_default_ids] = false url, model, scope = check_model(url, model, format, scope) if model if block form_tag_with_validators scope, model, , url, &block else = (url, model, **) form_tag_html() end end |