-
Notifications
You must be signed in to change notification settings - Fork 24
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
Adds invalid form example #12
base: main
Are you sure you want to change the base?
Conversation
… 422 with the invalid message
Folks, I've put this example in place because I wanted to ask y'all a question. I've tried asking around in the discuss forum, but haven't got any reply. After trying out Turbo Native I've noticed that invalid form responses work best with a 422 status code vs. a redirect to the form page. The former seems to replace the form while the latter will trigger a native navigation which will close native modals just to reopen it (you can read more about this and see the videos showing the behavior in an issue in the Turbo Laravel package here). So, my question is: should an invalid form submission always return a 422 status code with the form rendered (together with any validation message)? I'm asking because that's turning out to be quite hard to tackle in one particular edge-case of Turbo Laravel. We tend to use redirects in Laravel-land. If that's required, I was wondering if there would be any other way to instruct Turbo Native to only replace the form/frame without triggering a navigation (which causes the glitch). I've tried annotating the form with a Edit: just found this PR which I guess means forms don't use the |
Hey @jayohms, I'm curious if you have any thoughts here (sorry for the ping and no rush either) |
Yes, you want to avoid navigation for displaying form validation errors. This part of the documentation is the relevant part:
So, returning a |
@jayohms yep, that answers my question, thanks! I've read the docs a couple of times but the fact that the web version "just works" with redirects (which is the common behavior in Laravel) threw me off, haha. Thanks for pointing it out. The PR is working as described in the docs (see the linked video of the mobile behavior and screenshot of web behavior in the PR description). |
Awesome, thanks. I'll test this out on my end soon and merge over so we have a working example in the demo apps. |
Added
Android Video
invalid-forms-render.mp4
Web Screenshot