Reputation: 767
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
Upvotes: 16
Views: 34419
Reputation: 53
<input type="text" name="username" value="{{ old('username') }}">
you must also define withInput() for the http route when redirecting to a page for example
return back()->withInput();
Upvotes: 0
Reputation: 461
You can redirect with old data like below with validation error
return redirect()->back()->withErrors($validator)->withInput();
Upvotes: 8
Reputation: 54389
$username = Request::old('username');
or in view:
{{ old('username') }}
Read more: http://laravel.com/docs/5.0/requests#old-input
Upvotes: 36