I'm having one heck of an issue working out how to do this. I have 2 forms that need to be displayed next to each other but you can't embed forms, I got around this by just putting the 2nd form after the first one.
However, rails is ignoring my <% end %>
tag for the 2nd form and it is auto-closing the 2nd form before it needs to be closed. This is making my form not work.
Here's the view with some bits omitted for brevity.
<div class="row">
<div class="col-md-3">
<div class="well">
<%= render "shared/some_form", url_path: foo_path %>
<%= form_tag some_other_path, method: :delete, id: "form_bulk_action", role: "form" do %>
<div id="bulk_action_group">
<div class="form-group">
<%= label_tag "perform_bulk_action", "For each checked item" %>
<%= select_tag "perform_bulk_action", options_for_select([ ["Delete", "destroy"] ]), class: "form-control" %>
</div>
<%= button_tag id: "foo" %>
</div>
</div>
</div>
<div class="col-md-9">
<table class="table table-condensed table-hover">
<thead>
<tr>
<th><%= check_box_tag :check_all_data_rows, "", false %></th>
</tr>
</thead>
<tbody>
<% @foo.each do |foo| %>
<tr>
<td><%= check_box_tag "bulk_ids[]", foo.id, false, %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<% end %>
The partial that is loading some_form is the first form. The beginning and end of that form happens inside of the partial.
The second form is the form_tag. As you can see from the html markup we have a sidebar on the left and the main contents on the right being loaded in a table.
The idea of the 2nd form is it allows you to check off rows and then perform a bulk action on the checked off items. Similar to how you might mark 15 e-mails in gmail and then delete them.
The problem is rails is ignoring the <% end %>
at the bottom of that code snippet and instead it's injecting a </form>
right after the button with an id: foo
.
This is causing the bulk_ids value to always be nil because at that point the form is already closed and they are not part of the form. The crazy thing is it only fails when you goto the page from another page (ie. turbolinks). It works when you do a full load of the page, however I think the main issue is the premature closing of the </form>
tag.
How can I set this all up so the forms are not embedded and the 2nd form closes all the way at the bottom of the table while still using the form helpers?