Cannot submit form drawn by Rails Turbo Frame response

1k Views Asked by At

A form inside a turbo_frame is blocked from being submitted a second time.

Both the current page and the form action are the same path. I see forms now have to redirect to a new location or return an error code: turbo/pull/39.

I have a form on every index view sending a GET request to the index action, which filters the records based on the url query parameters. This works great. Is this no longer possible with latest Rails? Is there a workaround that could be applied here, to avoid creating a new route for the form action?

These are idempotent filter/search requests, hence the GET method. A form is a handy way to collect and send the filter values. Is it correct/intentional that Rails with Hotwire insists on a redirect in this scenario?

Update: It works if I submit the form as xhr instead of using Turbo. I add local: false and data-turbo: false to the form. Then add index.js.erb with document.getElementByID(<id of turbo frame>) and set its outerHTML to the rendered partial. Not sure if this will stop working due to deprecated ujs features (maybe mrujs can step in then).

0

There are 0 best solutions below