Adds fields_for_with_template method for use in views where JS is used to add/remove fields
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
MIT-LICENSE
README
Rakefile
init.rb
install.rb
uninstall.rb

README

Actionview-fieldsForWithTemplate
================================

Adds the following view helper for work with nested attributes:

  fields_for_with_template

This requires NumericSequence, available at github.com/mhs/numeric-sequence.

Example
=======

  <% @provider.schools.build if @provider.schools.reject(&:marked_for_destruction?).empty? -%>
  <% f.fields_for_with_template :schools do |school_form| %>
    <%= render :partial => "school", :locals => { :form => school_form } %>
  <% end %>

This will produce an additional template element containing the body of the fields for, ie:

  <div class="template">
    ... whatever render :partial => 'school' produced...
  </div>
  
It will replace all ids or counters with "NEW_RECORD". You need to supply the JavaScript to handle add, removing, etc, given this.

Copyright (c) 2009 Mutually Human Software, released under the MIT license