Dynamic input form in rails -
i trying add rows of input forms partial. of fields in partial have collection_select:
<td><%= label_tag :book_id, t("book") %></td> <td><%= collection_select :books, "books[:id]", book.all, :id, :name %></td>
the problem when dynamically add rows of kind last 1 passed controller in params. did not pass collection partial because dynamically added. appreciate if can me out one.
its because param name being replaced clones. can add counter:
<% (1..10).each |i| %> <td><%= collection_select :books, "books[#{i}][:id]", book.all, :id, :name %></td> <% end %>
of course, simple example. better control counter javascript events.
Comments
Post a Comment