You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a problem using Inertia forms inside a modal.
When some field does not pass the validation of the request in the backend (with a Form Request, for example), the modal reloads completely and does not save the content of the fields. The form.errors object is also empty. Using preserveState does not work either.
<?php
use Illuminate\Foundation\Http\FormRequest;
class StoreRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'name' => 'required|string|max:1',
];
}
}
Enter a value that breaks validation (in this case, a string longer than 1 character).
I'm not sure if this will help you, but I've experienced similar weirdness like this before, and what would end up resolving things is to completely wipe out the node_modules directory and package-lock.json and perform a fresh npm i.
What I do is add a "flush" script in my package.json:
"scripts": {
"dev": "vite",
"build": "vite build",
"flush": "rm -rf node_modules package-lock.json && npm i && npm run dev"
},
And then whenever I want to "reboot" things as mentioned above, I simply run npm run flush for convenience.
The other thing to verify that you are using the correct axios version (should be 1.2.0). I've been down this road a couple of times in projects wondering why the inertia forms aren't submitting/validating correctly, and the above "clean re-install" would resolve it.
There is a problem using Inertia forms inside a modal.
When some field does not pass the validation of the request in the backend (with a Form Request, for example), the modal reloads completely and does not save the content of the fields. The
form.errors
object is also empty. UsingpreserveState
does not work either.Steps to reproduce it:
package.json:
The text was updated successfully, but these errors were encountered: