Module: BetterForm::ViewHelper
- Defined in:
- lib/better_form/view_helper.rb
Instance Method Summary collapse
- #better_fields_for(record_or_name_or_array, *args, &proc) ⇒ Object
- #better_form_for(record_or_name_or_array, *args, &proc) ⇒ Object
- #label_all? ⇒ Boolean
- #validate_all? ⇒ Boolean
Instance Method Details
#better_fields_for(record_or_name_or_array, *args, &proc) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/better_form/view_helper.rb', line 24 def better_fields_for(record_or_name_or_array, *args, &proc) = args..reverse_merge(:builder => BetterForm::Builder) # Extract the better_form specific 'label' and 'validate_all' options @label_all = .delete(:label) @validate_all = .delete(:validate) # Call the standard Rails fields_for with our updated options fields_for(record_or_name_or_array, *(args << ), &proc) end |
#better_form_for(record_or_name_or_array, *args, &proc) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/better_form/view_helper.rb', line 3 def better_form_for(record_or_name_or_array, *args, &proc) = args..reverse_merge(:builder => BetterForm::Builder) # Call apply_form_for_options! here to have Rails set the class, id and method for the form as usual # We need to call this here (rather than implicitly through the later form_for call) because # apply_form_for_options! uses reverse_merge!, so out better_form class would override the new_whatever or # edit_whatever class applied by Rails (record_or_name_or_array, ) # Add the class 'better_form' to the list of classes for this form [:html] ||= {} [:html][:class] = "#{[:html][:class]} better_form" # Extract the better_form specific 'label' and 'validate_all' options @label_all = .delete(:label) @validate_all = .delete(:validate) # Call the standard Rails form_for with our updated options form_for(record_or_name_or_array, *(args << ), &proc) end |
#label_all? ⇒ Boolean
35 36 37 |
# File 'lib/better_form/view_helper.rb', line 35 def label_all? @label_all end |
#validate_all? ⇒ Boolean
39 40 41 |
# File 'lib/better_form/view_helper.rb', line 39 def validate_all? @validate_all end |