lundi 30 novembre 2015

Laravel 5.1 - Override default errors variables of the default login to differentiate between two forms on the same page

I am using Laravel 5.1 and i have a create form with a sidebar which also has a login form. Whenever i submit the create form and it has errors, i see the errors on both the login form and the create form. I understand why it's happening. I am using @include('errors.list') on both forms.

The list.php file inside errors

@if  ($errors->any())
        <div class="alert alert-danger alert-dismissible" role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            @foreach ($errors->all() as $error)
              <strong>• {{$error}}</strong><br/>
            @endforeach
        </div>
@endif

Now, i want to change the errors value on the login form when validation fails. I am using the default authentication form. I want to create something like if validation fails -> return with ('login_errors') instead of the default errors so i can use something like @if ($login_errors->any())

2nd question would be, how would i do the reverse without using custom validation? I am using $request, if i wanted to return the errors to the create form with custom_errors.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire