如果验证失败,我不清楚如何通过旧输入再次填写表格。
我的意思是,我知道如何在使用 Validator 类时传递数据,并在使用 withInput() 方法失败后重定向,但我正在尝试学习如何使用 laravel 5 中提供的表单请求。谢谢
如果验证失败,我不清楚如何通过旧输入再次填写表格。
我的意思是,我知道如何在使用 Validator 类时传递数据,并在使用 withInput() 方法失败后重定向,但我正在尝试学习如何使用 laravel 5 中提供的表单请求。谢谢
$username = Request::old('username');
或考虑到:
{{ old('username') }}
阅读更多: http: //laravel.com/docs/5.0/requests#old-input
您可以使用如下所示的旧数据重定向验证错误
return redirect()->back()->withErrors($validator)->withInput();
<input type="text" name="username" value="{{ old('username') }}">
例如,在重定向到页面时,您还必须为 http 路由定义 withInput()
return back()->withInput();