I am trying to link a button to insert a form for a new item. I want to be able to add a new form for each button click using turbo frames. I am having trouble incrementing the id of each frame so a new turbo frame is added instead of just replacing the old one. I do not want the data to save in my database until the user is done adding items and it is validated.
On my new bulk items page...
<%= button_to 'Add One', new_item_path,
data: { turbo_frame: dom_id(item.new)}, method: :get %>
<%= turbo_frame_tag dom_id(item.new) do %>
<% end %>
On my new item page...
<%= turbo_frame_tag dom_id(item.new) do %>
<%= simple_form_for [@item] do |f| %>
<% end %>
<% end %>
I saw a post that claimed success using this...
new_item_#{params.fetch(:index) + 1}
I have tried integrating it but get the same error 'param is missing or the value is empty: index', which I'm stuck on trying to pass in :index. How can I increment the index across both frames?