I have two forms on the same page.
The first one:
<%= form_with url: admin_users_path, method: :get,
class: "d-none d-md-inline-block me-auto w-100",
data: {
autosave_delay_value: 300,
controller: "autosave",
turbo_action: "advance",
turbo_frame: "users"
} do %>
<div class="input-group input-group-merge">
<%= text_field_tag "search", params[:search],
class: "form-control bg-white",
data: { action: 'keyup->autosave#save' },
placeholder: t("search", scope: "shared.action_name") %>
<span class="input-group-text bg-white">
<%= svg_icon("search-1", height: 16) %>
</span>
</div>
<% end %>
And second one:
<%= form_with url: admin_users_path, method: :get,
class: "d-none d-md-inline-block me-auto w-100",
data: {
controller: "autosave",
turbo_action: "advance",
turbo_frame: "users"
} do %>
<%= check_box_tag :confirmed, true, false, data: { action: 'autosave#save' }%>
<% end %>
To display filtered data i use:
<%= turbo_frame_tag "users" do %>
<div class="table-responsive">
<table class="table table-sm table-hover align-middle table-edge table-nowrap mb-0">
<thead class="thead-light">
<tr>....
....
If I search for a user by name in the first form, for example, type "John" the url looks like this: http://localhost:3000/admin/users?search=john
.
If I check the box in the second form the address changes to:
http://localhost:3000/admin/users?confirmed=true
This way I lose the search parameter.
The page is not reloaded, I just change the results.
How to pass this parameter between these forms?
Regards
Rails 7, Hotwire, Stimulus, Ruby 3.0.0, turb_frame_tag