Validation $errors is empty
Since recent updates $errors is always empty.
Plenty of others seeing problem: https://laracasts.com/discuss/channels/general-discussion/l5-form-errors-not-showing-up
Confirming this issue.
Confirmed as well. Still exists as of the latest commit.
Needs to be fixed. Can't develop / debug forms without it.
Not returning any errors, had to stop working on project, waiting for fix. Any clues how long it may take?
@Gibonek You can temporarily get around it by adding this to the top of your view:
<?php $errors = Session::has('errors') ? Session::get('errors') : $errors; ?>
Seems to be caused by the middleware stack being run through after the app has booted. So the session isn't properly set up when the view service provider attempts to grab the errors. Looking into a fix, although Taylor will probably be better suited to fixing this. Patience folks.
Thank you @alexleonard , I found better solution :
@if (Session::get('errors'))
<div class="alert alert-dismissable alert-warning">
<h4>Uwaga!</h4>
<ul>
@foreach (Session::get('errors')->all() as $error)
<li>{!! $error !!}</li>
@endforeach
</ul>
</div>
@endif
Now i got all in place, and working, many thanks for info that some hacks exist to go over this issue.
Sorry for bad English, i'm not native :)
You can add another cheap hack:
class FormErrorsMiddleware implements Middleware {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Session::has('errors')) {
view()->share('errors', \Session::get('errors'));
}
return $next($request);
}
}
and add this form error middleware to your AppServiceProvider $stack array ;)
Should be fixed with latest commits. Added new View\ErrorBinder middleware to stack so you'll want to add that to your stack.
It looks like there are still issues, since PHPUnit appears to be skipping Middleware:
1) App\Tests\Controller\AuthTest::testLoginPageLoads
ErrorException: Undefined variable: errors (View: /home/valorin/workspace/app/resources/views/auth/login.blade.php)
It loads fine in the browser.
@valorin this looks to be fixed in 23d7b9e046244ec5ef7c2ac9eade9e1545883fd2, handle now correctly fires the middleware stack.
Thanks :-) I can confirm it's now working as expected.