0

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',
        ]);
Dev
  • 1,013
  • 7
  • 15
  • 37

1 Answers1

1

Try this in view:

@if(Session::has('error'))
    {{ Session::get('error') }}
@endif
Calin Blaga
  • 1,375
  • 12
  • 19