Class: ActionView::Helpers::FormBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/nested_form_fields.rb

Instance Method Summary collapse

Instance Method Details



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, fields_options = {}, &block)
  fields_options, record_object = record_object, nil if record_object.is_a?(Hash) && record_object.extractable_options?
  fields_options[:builder] ||= options[:builder]
  fields_options[:parent_builder] = self
  fields_options[:wrapper_tag] ||= :fieldset
  fields_options[:legend] ||= nil
  fields_options[:namespace] = fields_options[:parent_builder].options[:namespace]

  return fields_for_has_many_association_with_template(record_name, record_object, fields_options, block)
end


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