I need to add a button that persists the data of the following form but that when pressing it resets the view and stays in it, without redirecting to the index of the controller, I have tried an ajax call but I don't know why it didn't work for me. How can I give a solution and add the button to save and continue?
<%= turbo_frame_tag dom_id(taxonomy) do %>
  <%= form_with(model: [:admin, taxonomy], id: dom_id(taxonomy)) do |form| %>
<div class="box">
  <div class="field is-horizontal">
    <div class="field-body">
      <div class="field">
        <div class="control is-expanded is-relative">
          <%= form.text_field :name, placeholder: true, class: "input mt-5" %>
          <%= form.label :name, class: "label-hidden required" %>
        </div>
      </div>
      <div class="field is-narrow">
        <div class="control mt-5">
          <%= form.submit nil, class: "button is-primary" %>
          <%= link_to "#{ t '.cancel'}", admin_taxonomies_path, class: "button is-light" %>
        </div>
      </div>
    </div>
  </div>
</div>
<% end %>
<% end %>
You need to add a target="_top" attribute to the frame: turbo_frame_tag dom_id(taxonomy), target: :_top
Otherwise Turbo tries to replace the current frame containing the form.
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