Pass old input after Form Request validation in la

2019-04-19 12:26发布

问题:

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

回答1:

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

or in view:

{{ old('username') }}

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



回答2:

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