15

如果验证失败,我不清楚如何通过旧输入再次填写表格。

我的意思是,我知道如何在使用 Validator 类时传递数据,并在使用 withInput() 方法失败后重定向,但我正在尝试学习如何使用 laravel 5 中提供的表单请求。谢谢

4

3 回答 3

33
$username = Request::old('username');

或考虑到:

{{ old('username') }}

阅读更多: http: //laravel.com/docs/5.0/requests#old-input

于 2015-03-23T15:46:09.650 回答
8

您可以使用如下所示的旧数据重定向验证错误

return redirect()->back()->withErrors($validator)->withInput();
于 2018-06-20T04:55:41.847 回答
0

<input type="text" name="username" value="{{ old('username') }}">

例如,在重定向到页面时,您还必须为 http 路由定义 withInput()

return back()->withInput();

于 2021-06-17T02:00:04.570 回答