I have an html table where the table rows are generated through a partial. The partial is wrapped in a form_with so I can delete multiple records with checkboxes. The issue is I want my button_tag outside of the form_with block. Is it possible to link the button_tag to the form so it doesn't have to be positioned inside the form block?
A dropdown action menu
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="actionMenuToggle" data-bs-toggle="dropdown" aria-expanded="false">Actions</button>
<ul class="dropdown-menu" aria-labelledby="actionMenu">
<li><%= button_tag "Delete Selected2", class: "btn btn-link dropdown-item", data: { action: "form-submission#destroyMultiple" } %></li>
</ul>
</div>
I then code my table skeleton as normal and my rows render the following partial
<%= render partial: "client_table", clients: @clients %>
and in that partial I have my form_with tag and loop to iterate through clients
<tbody id="clients">
<%= form_with(url: destroy_multiple_clients_path, data: { controller: 'form-submission', form_submission_target: "delete_multiple_form" }) do |form| %>
<% @clients.each do |client| %>
<tr>
<td><%= check_box_tag("client_ids[]", client.id, false, { class: "form-check-input", onclick: "onClientSelect();" }) %></td>
<td><%= client.id %></td>
<td><%= client.name %></td>
<td><%= client.city %></td>
<td><%= client.state_province %></td>
<td><%= client.postal_code %></td>
<td><%= link_to 'Edit', edit_client_path(client), class: "btn btn-success edit_client" %> </td>
</tr>
<% end %>
<% end %>
</tbody>