I just installed a Laravel Spark v4 - ran spark new project-name and followed the steps without any errors, the issue is that register form does not show any validation errors, not inline red warnings when input is not filled in or validation after the form is sent, what can be the issue? have not changed the generic register blade files.
When nothing is entered I get response code:
app.js:6175 POST http://127.0.0.1:8000/register 422 (Unprocessable Entity)
And the correct JSON response:
{"message":"The given data was invalid.","errors":{"name":["The name field is required."],"email":["The email field is required."],"password":["The password field is required."],"terms":["The terms must be accepted."]}}
Laravel's basic validation works on register form, but it does not work with AJAX request on login / register forms. Forms itself works when registering new users - but no feedback to the user.
I believe this has to do with Laravel's "Consistent Exception Handling" under the hood. The VueJS application for Spark isn't yet taking this into consideration.
To fix locally, around line 54 of /spark/resources/assets/js/forms/errors.js, in the this.set function, change:
if (typeof errors === 'object') {
this.errors = errors;
} else {...
to
if (errors.errors && (typeof errors.errors === 'object')){
this.errors = errors.errors;
} else {...
Recompile your JS, and it should begin working again.
I got the same problem right now after a new installation. I changed the code according to Paul's answer but it still doesn't work. Maybe the reason is that i don't know how to recompile the JS...
I did: rerun npm run dev, run php artisan view:clear, run php artisan cache:clear but this all didn't help. Sorry I'm totally new to laravel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With