Pass old input after Form Request validation in la

2019-04-19 12:17发布

if the validation fails it's not clear to me how i could pass the old input to fill again the form.

I mean, I know how to pass the data when using the Validator class and redirecting after fail with the method withInput(), but I'm trying to learn how to use Form Requests provided in laravel 5. Thanks

2条回答
聊天终结者
2楼-- · 2019-04-19 12:29
$username = Request::old('username');

or in view:

{{ old('username') }}

Read more: http://laravel.com/docs/5.0/requests#old-input

查看更多
迷人小祖宗
3楼-- · 2019-04-19 12:35

You can redirect with old data like below with validation error return redirect()->back()->withErrors($validator)->withInput();

查看更多
登录 后发表回答