ErrorBag is always empty in Laravel 5.2
Asked Answered
A

3

1

I was creating a new Laravel project and when debugging the errors of a form request, I noticed that my ErrorBag was always empty. Even when in the controller $validator->fails() returned true. I tried every solution I found on the internet but nothing worked.

Even when creating a fresh project with composer (as described here) my out of the box auth system has an empty error bag when leaving all the field empty.

And yes, all the routes are using the middleware group web.

Any ideas what is causing this problem? (Session::put() and Session::get() are working)

Anjanetteanjela answered 2/4, 2016 at 18:48 Comment(6)
Show your relevant code.Shiva
@Dees040 your code would help us help you faster ;)Obelisk
As of 5.2.27, released 8 days ago, all routes are by default in the web middleware group. If you've explicitly specified this group inside your routes file, try removing it, and let us know if that helps.Zwick
@Zwick Cheers mate, removing the routes from the web middleware worked like a charm. If you could make an answer of your comment I will mark it as the accepted answer.Anjanetteanjela
@Dees040 Done. Glad it worked out!Zwick
@Zwick yoo man...:) i stucked at this point from half of day...:) it's worked like a charm!! Thanks.Assuage
Z
4

As of v5.2.27, released on 2015-03-25, all routes in app\Http\routes.php are now in the web middleware group by default. If you have explicitly specified this middleware group inside your app\Http\routes.php file, you should remove it and that should resolve your issue.

Zwick answered 2/4, 2016 at 21:55 Comment(0)
A
1

In my case, I moved \Illuminate\Session\Middleware\StartSession::class from my web group to the $middleware array.

Armament answered 8/6, 2016 at 22:54 Comment(0)
O
0

Are you triggering any form validation errors? If you are then try this -

$messages = $validator->errors();

The messages variable should now have your errors

If you error bag is still empty

  • Check if your post data are being posted to the proper route/controller
Obelisk answered 2/4, 2016 at 19:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.