Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (17 sloc) 895 Bytes
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