app/helpers/admin/base_helper.rb
# This method demonstrates the use of the :child_index option to render a
# form partial for, for instance, client side addition of new nested
# records.
#
# This specific example creates a link which uses javascript to add a new
# form partial to the DOM.
#
#   <% form_for @project do |project_form| -%>
#     <div id="tasks">
#       <% project_form.fields_for :tasks do |task_form| %>
#         <%= render :partial => 'task', :locals => { :f => task_form } %>
#       <% end %>
#     </div>
#   <% end -%>
This method demonstrates the use of the :child_index option to render a
form partial for, for instance, client side addition of new nested
records.

This specific example creates a link which uses javascript to add a new
form partial to the DOM.


This method demonstrates the use of the : child_index option to render a form partial for for instance client side addition of new nested records . This specific example creates a link which uses javascript to add a new form partial to the DOM .
def generate_html(form_builder, method, options = {})
    options[:object] ||= form_builder.object.class.reflect_on_association(method).klass.new
    options[:partial] ||= method.to_s.singularize
    options[:form_builder_local] ||= :f  
    form_builder.fields_for(method, options[:object], :child_index => 'NEW_RECORD') do |f|
      render(:partial => options[:partial], :locals => { options[:form_builder_local] => f })
    end
  end
def generate_html ( form_builder , method , options = { } ) options [ :object ] ||= form_builder . object . class . reflect_on_association ( method ) . klass . new options [ :partial ] ||= method . to_s . singularize options [ :form_builder_local ] ||= :f form_builder . fields_for ( method , options [ :object ] , :child_index => 'NEW_RECORD' ) do | f | render ( :partial => options [ :partial ] , :locals => { options [ :form_builder_local ] => f } ) end end
This method demonstrates the use of the :child_index option to render a
form partial for, for instance, client side addition of new nested
records.
This method demonstrates the use of the : child_index option to render a form partial for for instance client side addition of new nested records .
form_builder
<not_specific>
method
<not_specific>
options
<not_specific>