-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Form responses must redirect to another location #22
Comments
So I ended up creating a patch for now to get it working on my end https://github.com/cj/app-template/blob/main/patches/%40hotwired%2Bturbo%2B7.0.0-beta.1.patch, but it led to what might be a bug with This is where I am calling |
ah so the |
I'm running into this issue as well with simple form submissions that re-render the form (i.e. the HTML page) with errors when server validation fails. Is there a reason for this behavior? Is it documented? |
We intend to allow HTTP 422 responses for form submissions inside frames, but it didn’t make the cut for the initial beta release. For now, you can try sending a Turbo Streams response that re-renders your form with errors. |
Browsers record form submissions in history along with the verb. In a standard "postback" scenario, if you reload the page after submission, or navigate away and then back, you'll see a dialog box like this: The forms-must-redirect constraint is what allows us to keep the browser's back, forward, and reload buttons working after any form submission, and without showing a dialog box, since all form submissions result in a visit and all visits are idempotent GET requests. |
Thanks for the explanation @sstephenson. I’m probably misunderstanding something, but can’t quite see why swapping in HTML returned by the form submission (or even simulating a full page visit using the HTML response) would mess with the browser history... If the form submission is an ajax request, does the browser put the POST or PUT request in its history? If not, why would it be a problem to render HTML returned with a 200 response, in the same way 400-500 responses can now be rendered? 🙇♂️ |
Hi,
I am using https://viewcomponent.org/ and I am handling redirects for forms using stimulus doing the following:
But it currently throws this error
Error: Form responses must redirect to another location
, which is due to the following codeturbo/src/core/drive/form_submission.ts
Line 103 in aae160b
Cheers!
The text was updated successfully, but these errors were encountered: