I know there are multiple questions with a similar title to this, but I haven't found anything that resembled my problem. If there is already a solution and thus my question is a duplicate, I'm sorry - I just didn't find it, it's not that I didn't search.
I'm using ActiveAdmin with the ActiveSkin theme. I have a form for my model Agent
where I want to use the nested forms for a has_many
relation. I created this code in a partial:
<%= semantic_form_for [@agent], builder: ActiveAdmin::FormBuilder do |f| %>
<%= f.semantic_errors %>
<%= f.inputs 'General Information' do %>
<%= f.input :name %>
<%= f.input :description %>
<% end %>
<%= f.inputs 'Capture Columns' do %>
<%= f.has_many :capture_columns, new_record: 'Add Column' do |column| %>
<%= column.input :column_name %>
<%= column.input :column_datatype %>
<% end %>
<% end %>
<%= f.actions do %>
<%= f.action :submit %>
<li class="cancel"><%= link_to 'Cancel', :back %></li>
<% end %>
<% end %>
Basically, this is working, but it looks like this:
Why is the html duplicated (I checked it, it's exactly the same)? What am I doing wrong?
EDIT: The inner HTML for the nested form is duplicated, too:
Not saying it's the right behavior, but according to the docs, you need to avoid printing to the template when using has_many
.
Try using <%-
or <%
instead of <%=
in the f.has_many
declaration and block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With