Issue
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',
]);
Solution
Try this in view:
@if(Session::has('error'))
{{ Session::get('error') }}
@endif
Answered By - Calin Blaga
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.