-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
Hi!
I'm trying to implement the second level of nesting form. but if I add first level form, the second level of add / remove button doesn't work.
Model:
Model has many Musics
Music has many MusicDetails
the code is below.
<div class="table-responsive">
<%= f.nested_fields_for :musics, wrapper_tag: :table, wrapper_options: { class: 'table table-striped \
table-hover table-bordered center', align: 'center', cellpadding: '3' } do |g| %>
<tr>
<th colspan="5" class="bg-warning">Score Music</th>
</tr>
<tr>
<th>Music Name</th>
<td colspan="3"><%= g.text_field :name, class: 'form-control', style: 'width: 500px' %></td>
<td><%= g.remove_nested_fields_link 'Delete', class: 'btn btn-danger', role: 'button' %></td>
</tr>
<tr>
<th>Difficulty</th>
<th>Lv</th>
<th>Theoretical Score</th>
<th>Coefficient</th>
<th>Delete</th>
</tr>
<%= g.nested_fields_for :music_details, wrapper_tag: :tr do |h| %>
<td><%= h.collection_select :difficulty_id, model.difficulties, :id, :name, { class: 'form-control form-inline', style: 'width: 300px' } %></td>
<td><%= h.number_field :level, step: 0.01, class: 'form-control' %></td>
<td><%= h.number_field :theoretical_score, class: 'form-control' %></td>
<td><%= h.number_field :coefficient, step: 0.01, class: 'form-control' %></td>
<td><%= h.remove_nested_fields_link 'Delete', class: 'btn btn-danger', role: 'button' %></td>
<% end %>
<tr>
<td colspan="5"><%= g.add_nested_fields_link :music_details, 'Add new', class: 'btn btn-primary', role: 'button' %></td>
</tr>
<tr>
<th>Note</th>
<td colspan="4"><%= g.text_area :note, class: 'form-control', size: '80x2' %> </td>
</tr>
<% end %>
<%= f.add_nested_fields_link :musics, 'Add new', class: 'btn btn-primary', role: 'button' %>
</div>
I noticed when first level form(music form) is added, the script tag is not copied to the added form.
I can't add form to the added form?
Metadata
Metadata
Assignees
Labels
No labels