Hi everyone!
I've got a nested form like this :
<% form_for setup_training(@training), :url => admin_trainings_path, :html => { :class => :form } do |f| -%>
<!-- begin of form -->
<!-- content of :partial => "day_form" -->
<% f.fields_for :days do |days_form| %>
<%= render :partial => "admin/days/form_inner", :locals => { :f => days_form }%>
<% end %>
<!-- end of content of :partial => "day_form" -->
<%= link_to_function("[+] Ajouter une date", nil, :id => "add-place-and-dates-link") do |page|
page.insert_html :bottom, "place-and-dates-inner", :partial => "day_form", :locals => { :f => f }
end %>
<% end -%>
The first time i load my page, the first fields_for block has id 0;
The first time i click on "add a date", a new fields_for block is created with id = 1;
Then, everytime i clink on "add a date", a new fields_for block is displayed, but the id stays to 1.
An HTML example may be more explicit, here's the output i've got :
<!-- This part is generated when i display /new, id is 0 -->
<label class="label" for="training_days_attributes_0_place_id">Lieu</label>
<input class="text_field" id="training_days_attributes_0_place_id" name="training[days_attributes][0][place_id]" size="30" type="text">
<!-- This part is generated when i click on "add a new date", id is 1 -->
<label class="label" for="training_days_attributes_1_place_id">Lieu</label>
<input class="text_field" id="training_days_attributes_1_place_id" name="training[days_attributes][1][place_id]" size="30" type="text">
<!-- This part is generated when i click on "add a new date" a second time, id is 1, but it should be 2 -->
<label class="label" for="training_days_attributes_1_place_id">Lieu</label>
<input class="text_field" id="training_days_attributes_1_place_id" name="training[days_attributes][1][place_id]" size="30" type="text">
Thank you per advance for you help!