Trying to create a nested form in rails, but have it collapsible using bootstrap tabs.
I currently have the following:
_form.html.rb
<%= f.fields_for :register_members do |rm| %>
<%= render 'register_member_fields', f: rm %>
<% end %>
<div class="links">
<%= link_to_add_association "Add Registration", f, :register_members, class: "btn btn-success btn-sm text-white" %>
</div>
_register_member_fields.html.erb
<div class="nested-fields">
<div class="panel panel-default fields">
<div class="panel-heading" role="tab" id="heading<%= f.index.to_s %>">
<h4 class="panel-title">
<a data-toggle="collapse" href="#tabCollapse<%= f.index.to_s %>" aria-expanded="true" aria-controls="tabCollapse<%= f.index.to_s %>">
Registration
<span class="panel-icon"></span>
</a>
</h4>
</div><!-- End .panel-heading -->
<div id="tabCollapse<%= f.index.to_s %>" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading<%= f.index.to_s %>">
<div class="panel-body">
<div class="field">
<%= f.label "Name", class: "input-desc" %>
<%= f.text_field :name, class: "form-control" %>
</div>
<div class="field">
<%= f.label :email, class: "input-desc" %>
<%= f.email_field :email, class: "form-control" %>
</div>
<div class="field">
<%= f.hidden_field :_destroy %>
<%= link_to_remove_association("Remove Registration", f) %>
</div>
</div><!-- End .panel-body -->
</div><!-- End .panel-collapse -->
</div><!-- End .panel -->
</div>
Obviously with how nested fields work using the gem cocoon
this will create a new _register_member_field
using the same id
for the collapse. Which means clicking on any of the panel headings will only collapse and open one of the nested forms.
Any suggestions on how I can get this to work properly?