Module: Para::FormBuilder::AttributesMappingsTracker
- Defined in:
- lib/para/form_builder/attributes_mappings_tracker.rb
Instance Method Summary collapse
- #attributes_mappings_field_for(fields) ⇒ Object
- #fields_for(*args, &block) ⇒ Object
-
#initialize ⇒ Object
:nodoc:.
- #input(attribute_name, options = {}, &block) ⇒ Object
- #input_field(attribute_name, options = {}) ⇒ Object
Instance Method Details
#attributes_mappings_field_for(fields) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/para/form_builder/attributes_mappings_tracker.rb', line 41 def attributes_mappings_field_for(fields) return unless [:track_attribute_mappings] hidden_field :_attributes_mappings, value: @attributes_mappings.to_json, data: { :'attributes-mappings' => fields.[:child_index] } end |
#fields_for(*args, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/para/form_builder/attributes_mappings_tracker.rb', line 22 def fields_for(*args, &block) = args. track_attribute_mappings = ( [:track_attribute_mappings] != false && [:track_attribute_mappings] ) .reverse_merge!( track_attribute_mappings: track_attribute_mappings ) super(*args, ) do |fields| fields_html = @template.capture { block.call(fields) } fields_html + fields.attributes_mappings_field_for(fields) end end |
#initialize ⇒ Object
:nodoc:
4 5 6 7 8 |
# File 'lib/para/form_builder/attributes_mappings_tracker.rb', line 4 def initialize(*) #:nodoc: @attributes_mappings = {} super end |
#input(attribute_name, options = {}, &block) ⇒ Object
10 11 12 13 14 |
# File 'lib/para/form_builder/attributes_mappings_tracker.rb', line 10 def input(attribute_name, = {}, &block) store_attribute_mapping_for(attribute_name, , &block) super(attribute_name, , &block) end |
#input_field(attribute_name, options = {}) ⇒ Object
16 17 18 19 20 |
# File 'lib/para/form_builder/attributes_mappings_tracker.rb', line 16 def input_field(attribute_name, = {}) store_attribute_mapping_for(attribute_name, ) super(attribute_name, ) end |