Reputation: 1073
I use withErrors()
to pass validation messages in template blade:
if ($validator->fails()) {
dd($validator); // Gives me filled array with messages
return Redirect::back()
->withErrors($validator)
->withInput();
In template I have:
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
I am guess that problem in the call stack of templates blade, or in function withErrors
.
If withErrors
uses session, maybe this is one of problem.
Additionally this is my call validation:
$validator = Validator::make($request->all(), [
"name" => 'required|string|min:10',
"text" => 'required|string|min:10',
]);
Upvotes: 0
Views: 2501
Reputation: 1373
Try this in view:
@if(Session::has('error'))
{{ Session::get('error') }}
@endif
Upvotes: 1