I just realized that Firebug doesn't correctly display what content is in what tags. The source file says this:
<tbody class = "fields"> <tr><label class="name" for="echantillon_treatments_attributes_1_treatmenttype">type de traitement</label> <input id="echantillon_treatments_attributes_1_treatmenttype" name="echantillon[treatments_attributes][1][treatmenttype]" size="30" type="text" /></tr> <tr><label class="name" for="echantillon_treatments_attributes_1_treatmenttype">commentaires sur la preparation</label> <input id="echantillon_treatments_attributes_1_preparation" name="echantillon[treatments_attributes][1][preparation]" size="30" type="text" /></tr> <tr><input id="echantillon_treatments_attributes_1__destroy" name="echantillon[treatments_attributes][1][_destroy]" type="hidden" / > </tr> <tr><input id="echantillon_treatments_attributes_1__destroy" name="echantillon[treatments_attributes][1][_destroy]" type="hidden" / ><a href="#" onclick="remove_fields(this); return false;">remove</a></ tr> </tbody> while firebug says that the fields are actually outside of the <tr> tags. Why would that be? Also, why is it putting two hidden fields (shown above in the source code) in the form while my view file says only this: <tbody class = "fields"> <tr><%= f.label(:treatmenttype, "type de traitement", :class => "name") %> <%= f.text_field :treatmenttype %></tr> <tr><%= f.label(:treatmenttype, "commentaires sur la preparation", :class => "name") %> <%= f.text_field :preparation %></tr> <tr><%= f.hidden_field :_destroy %> </tr> <tr><%= link_to_remove_fields "remove", f %></tr> </tbody> On Apr 12, 5:29 pm, Ryan Bates <[email protected]> wrote: > You need to nest the table content inside <tr><td> ... </td></tr> > tags. It's not valid HTML otherwise. > > Regards, > > Ryan > > On Apr 12, 7:53 am, ES <[email protected]> wrote: > > > I'm following this nested forms > > railscasthttp://railscasts.com/episodes/197-nested-model-form-part-2 > > > but each time that new fields are added to my form the fields are > > added above my table. Therefore, when the remove links are clicked, > > it can't find the section to delete. What am I doing wrong? > > > in the view: > > > <tbody> > > > <% echantillon_form.fields_for :treatments do |builder| %> > > <%= render "treatment_fields", :f => builder %> > > <% end %> > > > <%= link_to_add_fields "Add treatment", > > echantillon_form, :treatments %> > > > <%= echantillon_form.submit "Submit" %> > > <% end %> > > </tbody> > > </table> > > > in the partial: > > > <div class = "fields"> > > > <%= f.label(:treatmenttype, "type de traitement", :class => "name") %> > > <%= f.text_field :treatmenttype %> > > > <%= f.label(:treatmenttype, "commentaires sur la preparation", :class > > => "name") %> > > <%= f.text_field :preparation %> > > > <%= f.hidden_field :_destroy %> > > > <%= link_to_remove_fields "remove", f %> > > > </div> > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

