Replies: 1 comment
-
EDIT: I battled to get something working... All I wanted was to respond to an Inertia request with an error to display in a form (in case a field did not match the proper format, for example), but without a "component" thing (i.e. without a full page visit with all that it implies). I spent all night and all day on it, getting (more or less...) help from Phind. My solution is complicated, because now I am manually sending an event to Inertia for loading the next Page if the POST request ended well, and I am manually calling |
Beta Was this translation helpful? Give feedback.
-
Hi there!
I am not sure I totally understand how Inertia works (i.e. what it is expecting in this or that situation).
I can show you below what I understood about what is expected, but I would be really grateful if someone could correct me, show me where I am wrong, so that I have a perfect summary of what kind of Inertia responses I must provide in different situations.
1. Loading a page, or redirecting to another page
Standard response
EDIT: I don't have much doubt about this one
2. Field error upon form submit
Ajax form submit, validation PHP side (well, server side). Provide "errors" prop.
Questions:
3. Actual location redirect
When requiring a real redirect from the browser
No page data, as we redirect the user to new horizons!
4. Submit form success
When we don't redirect to another component (like we could do when adding a user and redirecting to their details)
I am not sure which response is required here... Maybe it depends on whether I want to display a specific (server-rendered) message upon success, or maybe I don't want to display anything...
Do I have to do a full-blown "page load" response? Or can I just respond "200 OK" or something?
Summary: I would like to be able to write, without any fears of doing it wrong, the handling of different situations in my own Inertia adapter: onFormFieldError, onFormGenericError, onFormSuccess, onLoadPage, onActualRedirect
But I am not quire sure whether I am currently handling the requests properly...
Any help to see things more clearly would be super welcome! :)
Best,
Beta Was this translation helpful? Give feedback.
All reactions