Search code examples
phplaravellaravel-5laravel-validation

Laravel 5, $errors array is always empty when using withErrors($validator)


Controller:

if ($validator->fails()) {
    return redirect()->back()
        ->withInput($data)
        ->withErrors($validator->errors());
}

Here's the dump of $validator->errors() using dd:

enter image description here

BUT unfortunately in view I'm getting $errors as empty ViewErrorBag object:

enter image description here

What I'm doing wrong?


Solution

  • If you can dump the errors before passing to the view, but get it empty on your view, so it's a problem with your Session. Try checking your config/session.php and also setting one value at one page using Session::put() and grabbing it back with Session::get() at another page to see if it is working properly.