# Partial being rendered outside of table format

**URL:** <https://www.ruby-forum.com/t/partial-being-rendered-outside-of-table-format/186804>\
**Category:** Rails\
**Created:** [April 12, 2010, 4:55pm UTC](https://www.ruby-forum.com/t/partial-being-rendered-outside-of-table-format/186804 "2010-04-12T16:55:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ESESES](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f0a364/32.png) [@ESESES](https://www.ruby-forum.com/u/ESESES)\
**Post date:** [April 12, 2010, 4:55pm UTC](https://www.ruby-forum.com/t/partial-being-rendered-outside-of-table-format/186804/1 "2010-04-12T16:55:00Z")

</div>

I’m following this nested forms railscast

> **[\#197 Nested Model Form Part 2 - RailsCasts](http://railscasts.com/episodes/197-nested-model-form-part-2)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

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:

```
    <% 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 %\>

in the partial:

\<%= 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 class="post-metadata">

**Author:** ![ESESES](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f0a364/32.png) [@ESESES](https://www.ruby-forum.com/u/ESESES)\
**Post date:** [April 12, 2010, 5:30pm UTC](https://www.ruby-forum.com/t/partial-being-rendered-outside-of-table-format/186804/2 "2010-04-12T17:30:43Z")

</div>

You need to nest the table content inside

 …   
tags. It’s not valid HTML otherwise.

Regards,

Ryan

---

<div class="post-metadata">

**Author:** ![ESESES](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f0a364/32.png) [@ESESES](https://www.ruby-forum.com/u/ESESES)\
**Post date:** [April 12, 2010, 8:32pm UTC](https://www.ruby-forum.com/t/partial-being-rendered-outside-of-table-format/186804/3 "2010-04-12T20:32:48Z")

</div>

On 12 April 2010 16:59, ES [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> name=“echantillon[treatments\_attributes][1][treatmenttype]” size=“30”
> 
> \<input id="echantillon\_treatments\_attributes\_1\_\_destroy"
> 
> while firebug says that the fields are actually outside of the   
> tags. Why would that be?

I think you have invalid html. I highly recommend installing the html  
validator add-in for firefox as it checks my html as I develop the  
app, making sure I do not make such errors. Also you can paste your  
html into the w3c htlm validator (find with google if necessary) to  
check it.

Colin

---

<div class="post-metadata">

**Author:** ![ESESES](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f0a364/32.png) [@ESESES](https://www.ruby-forum.com/u/ESESES)\
**Post date:** [April 12, 2010, 6:01pm UTC](https://www.ruby-forum.com/t/partial-being-rendered-outside-of-table-format/186804/4 "2010-04-12T18:01:10Z")

</div>

I just realized that Firebug doesn’t correctly display what content is  
in what tags. The source file says this:

type de traitement commentaires sur la preparation

remove

while firebug says that the fields are actually outside of the

  
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:

\<%= 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 %\>
