Laravel Blade View - 未定义变量:错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26371071/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel Blade View - Undefined variable: errors
提问by Zulakis
When accessing the login page of my laravel application I get a Undefined variable: errors (View: D:\PhpstormProjects\laravel\resources\views\login.blade.php)
error.
访问我的 Laravel 应用程序的登录页面时,出现Undefined variable: errors (View: D:\PhpstormProjects\laravel\resources\views\login.blade.php)
错误。
According to http://laravel.com/docs/master/validation#error-messages-and-views, $errors should always automatically be set:
根据http://laravel.com/docs/master/validation#error-messages-and-views, $errors 应始终自动设置:
So, it is important to note that an $errors variable will always be available in all of your views, on every request, allowing you to conveniently assume the $errors variable is always defined and can be safely used.
因此,重要的是要注意 $errors 变量将始终在您的所有视图中可用,在每次请求时,您都可以方便地假设 $errors 变量始终已定义并且可以安全使用。
This is the blade file:
这是刀片文件:
@extends('layouts.master')
@section('main')
<div id="loginwrapper">
<h2>Please authenticate</h2>
@if ($errors->has())
<div id="error">
{{ $errors->first() }}
</div>
@endif
{!! Form::open(['id' => 'loginform', 'name' => 'loginform']) !!}
... Form stuff ...
{!! Form::close() !!}
</div>
@stop
The view is being generated by a simple View::make('login');
I am using the laravel 5.0 development version.
该视图是由一个简单的View::make('login');
我使用 laravel 5.0 开发版本生成的。
Does anyone know the reason for this?
有谁知道这是什么原因?
采纳答案by Zulakis
This was an error in the framework, just fixed today: https://github.com/laravel/laravel/commit/a9bddfc0e0573aa2b6d9d553126e9bf0af064e7b
这是框架中的一个错误,今天刚刚修复:https: //github.com/laravel/laravel/commit/a9bddfc0e0573aa2b6d9d553126e9bf0af064e7b