Module: SimpleFormWithClientValidation::ActionViewExtensions::FormHelper
- Defined in:
- lib/simple_form_with_client_validation/action_view_extensions/form_helper.rb
Overview
This module creates SimpleFormWithClientValidation wrappers around default form_for and fields_for.
Example:
simple_form_for @user do |f|
f.input :name, :hint => 'My hint'
end
Constant Summary collapse
- FIELD_ERROR_PROC =
Override the default ActiveRecordHelper behaviour of wrapping the input. This gets taken care of semantically by adding an error class to the wrapper tag containing the input.
proc do |html_tag, instance_tag| html_tag end
- @@default_field_error_proc =
based on what is done in formtastic github.com/justinfrench/formtastic/blob/master/lib/formtastic.rb#L1706
nil
Instance Method Summary collapse
- #simple_fields_for(record_name, record_object = nil, options = {}, &block) ⇒ Object
- #simple_form_for(record, options = {}, &block) ⇒ Object
Instance Method Details
#simple_fields_for(record_name, record_object = nil, options = {}, &block) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/simple_form_with_client_validation/action_view_extensions/form_helper.rb', line 37 def simple_fields_for(record_name, record_object = nil, = {}, &block) , record_object = record_object, nil if record_object.is_a?(Hash) && record_object. [:builder] ||= SimpleFormWithClientValidation::FormBuilder with_simple_form_field_error_proc do fields_for(record_name, record_object, , &block) end end |
#simple_form_for(record, options = {}, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/simple_form_with_client_validation/action_view_extensions/form_helper.rb', line 24 def simple_form_for(record, ={}, &block) [:builder] ||= SimpleFormWithClientValidation::FormBuilder [:html] ||= {} unless [:html].key?(:novalidate) [:html][:novalidate] = !SimpleFormWithClientValidation.browser_validations end [:html][:class] = [SimpleFormWithClientValidation.form_class, simple_form_css_class(record, )].compact.join(" ") with_simple_form_field_error_proc do form_for(record, , &block) end end |