2

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).

rigyt
  • 2,219
  • 3
  • 28
  • 40
  • Does it help to add a dummy parameter like "now: (new Date()).getTime()" to produce a different get every time ? No experience with hotwire but it's what I use in my javascript when I send stuff to the server. – peter Sep 06 '21 at 19:20
  • No it's the same when params are different in each request – rigyt Sep 06 '21 at 21:30

0 Answers0