Dear mailing list,
As requested by rafaelfranca in my GitHub issue -
https://github.com/plataformatec/simple_form/issues/590 - I'm going to
repost my question here. He asked me to attach the code for
link_to_add, but I'm uncertain about what he's asking for. I'm using
the provided link_to_add method from nested_form / simple_form.
I'm having issues configuring a custom wrapper so that link_to_add
automatically adds a new <tr> to an existing table. Here is my current
(simplified) markup:
---
<%= simple_nested_form_for @user, :html => {:class => "form-
horizontal"} do |f| %>
<%= f.input :username %>
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Description</th>
<th colspan="2">Label</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<%= f.simple_fields_for :user_events, :wrapper => :event_table
do |e| %>
<tr>
<td><%= e.input_field :date, :as => :date_month_year %></td>
<td><%= e.input_field :description %></td>
<td><%= e.input_field :label %></td>
<td><%= e.input_field :label_class %></td>
<td><%= e.link_to_remove "Delete this event." %></td>
</tr>
<% end %>
</tbody>
</table>
<%= f.link_to_add :user_events, "Add new event" %>
<% end %>
---
This is my custom wrapper from config/initializers/simple_form.rb:
---
config.wrappers :event_table, :tag => 'tr' do |b|
b.use :html5
b.use :placeholder
b.wrapper :tag => :td do |input|
input.use :input
end
end
---
The default wrapper used for the main form (not the nested one)
is :bootstrap.
I already restarted the server several times, but I always experience
that the new fields added by link_to_addget wrapped wrong and at the
wrong position in the markup.
I'm looking forward to your help. With best regards,
Alex