Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Fortify validation errors not working

I'm trying Fortify since one week now and I'm stuck on the same problem at two level.

The problem is when I try to update user password, it doesn't show me validation errors (I mean, when for test purpose I leave fields blank).

The same thing when I try to update user informations (name, email... when I leave them blank for test purpose).

Of course I tried to iterate the $errors variable to display errors message on my views but nothing. I also tried with the @error blade directive but nothing too.

Here's my update password view where I perform an PUT submit to the user-password.update route defined by Fortify

enter image description here

Thanks for your help.

like image 327
Jacques Rollins Avatar asked Oct 16 '25 23:10

Jacques Rollins


2 Answers

You can use the following code in your blade

@if ($errors->updatePassword->any())
     <ul>
         @foreach($errors->updatePassword->all() as $error)
            <li>{{ $error }}</li>
         @endforeach
     </ul>
@endif

This "$errors->updatePassword" is the Bag Name which will be found in "app/Actions/Fortify/UpdateUserPassword.php"

like image 138
MNI Noyon Avatar answered Oct 18 '25 14:10

MNI Noyon


its work

@if ($errors->updatePassword->any())
 <ul>
     @foreach($errors->updatePassword->all() as $error)
        <li>{{ $error }}</li>
     @endforeach
 </ul>
@endif

or you can change method validateWithBag('updatePassword') in "app/Actions/Fortify/UpdateUserPassword.php" with validate()

like image 20
arul project Avatar answered Oct 18 '25 15:10

arul project



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!