Class: NestedForm::Builder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- NestedForm::Builder
- Defined in:
- lib/nested_form/builder.rb
Instance Method Summary collapse
- #fields_for_nested_model(name, association, args, block) ⇒ Object
- #fields_for_with_nested_attributes(association, args, block) ⇒ Object
- #link_to_add(name, association) ⇒ Object
- #link_to_remove(name) ⇒ Object
Instance Method Details
#fields_for_nested_model(name, association, args, block) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/nested_form/builder.rb', line 27 def fields_for_nested_model(name, association, args, block) # output = '<div class="fields">'.html_safe # output << super # output.safe_concat('</div>') # output super.html_safe end |
#fields_for_with_nested_attributes(association, args, block) ⇒ Object
20 21 22 23 24 |
# File 'lib/nested_form/builder.rb', line 20 def fields_for_with_nested_attributes(association, args, block) @fields ||= {} @fields[association] = block super end |
#link_to_add(name, association) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/nested_form/builder.rb', line 3 def link_to_add(name, association) @fields ||= {} @template.after_nested_form(association) do model_object = object.class.reflect_on_association(association).klass.new output = %Q[<textarea id="#{association}_fields_blueprint" style="display: none">].html_safe output << fields_for(association, model_object, :child_index => "new_#{association}", &@fields[association]) output.safe_concat('</textarea>') output end @template.link_to(name, "javascript:void(0)", :class => "add_nested_fields", "data-association" => association) end |
#link_to_remove(name) ⇒ Object
15 16 17 |
# File 'lib/nested_form/builder.rb', line 15 def link_to_remove(name) hidden_field(:_destroy) + @template.link_to(name, "javascript:void(0)", :class => "remove_nested_fields") end |