Using tubro_frame in Rails, how to submit a form which is inside the turbo frame without reloading it?
Sample code:
<%= turbo_frame_tag "sample-frame" do %>
<%= form_with(model: model, url: sample_p_url, method: :put) do |f| %>
#other fields here
<%= f.submit "Save" %>
<% end %>
<% end %>
Issue: When submitting the form, it also reloads the frame.
I tried to supply data: {turbo: true) or data: {remote: true} to form but not working
If you want this form to remain on the page and update a different part of the page, then you would need for the form to be outside of the
turbo-frame. Then, you can explicitly set the frame that this form controls by setting adata-turbo-frameattribute for the form. Turbo Docs: Targeting Into or Out of a FrameHowever, if you wish to allow your form to submit multiple times, I would suggest allowing it to reload as a fresh form on the page, so that you get a fresh
authenticity_token.