Class: ActionView::Helpers::FormBuilder
- Inherits:
-
Object
- Object
- ActionView::Helpers::FormBuilder
- Defined in:
- lib/nested_form_fields.rb
Instance Method Summary collapse
- #add_nested_fields_link(association, text = nil) ⇒ Object
- #nested_fields_for(record_name, record_object = nil, fields_options = {}, &block) ⇒ Object
- #remove_nested_fields_link(text = nil) ⇒ Object
Instance Method Details
#add_nested_fields_link(association, text = nil) ⇒ Object
26 27 28 29 30 |
# File 'lib/nested_form_fields.rb', line 26 def add_nested_fields_link association, text = nil @template.link_to text || "Add #{association.to_s.singularize.humanize}", '', class: "add_nested_fields_link", data: { association_path: association_path(association.to_s) } end |
#nested_fields_for(record_name, record_object = nil, fields_options = {}, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nested_form_fields.rb', line 14 def nested_fields_for(record_name, record_object = nil, = {}, &block) , record_object = record_object, nil if record_object.is_a?(Hash) && record_object. [:builder] ||= [:builder] [:parent_builder] = self [:wrapper_tag] ||= :fieldset [:legend] ||= nil [:namespace] = [:parent_builder].[:namespace] return fields_for_has_many_association_with_template(record_name, record_object, , block) end |
#remove_nested_fields_link(text = nil) ⇒ Object
32 33 34 35 36 |
# File 'lib/nested_form_fields.rb', line 32 def remove_nested_fields_link text = nil @template.link_to text || 'x', '', class: "remove_nested_fields_link", data: { delete_association_field_name: delete_association_field_name } end |