ryanb / nested_form

Rails plugin to conveniently handle multiple models in a single form.
MIT License
1.79k stars 505 forks source link

'marked_for_destruction' not appended to 'fields' class when using wrapper: false #357

Open tbrammar opened 8 years ago

tbrammar commented 8 years ago

Hi,

I have the following code:

<table id="js_user_permissions" >
  <%= nested_form_for(user) do |f| %>
    ....
    <%= f.fields_for :permissions, wrapper: false do |p| %>
      <tr class="fields">
        <td>
          <%= p.select :country_id, countries.collect {|c| [ c.name, c.id ] } %>
        </td>
        <td>
          <%= p.link_to_remove "Remove" %>
          <p></p>
        </td>
      </tr>
    <% end %>
    <%= f.link_to_add "Add permissions", :permissions, data: { target: "#js_user_permissions" } %>
  <% end %>
</table>

Everything works as expected: I can add new permissions to new records / existing records, I can remove permissions from existing records etc.

However, with validations I can't seem to get the marked_for_destruction class added to my <tr class="fields"> tag.

If I remove a permission from an existing record, submit the form and then it fails validation the re-rendered form doesn't display the marked_for_destruction class on that DOM.

Any ideas?