I am wondering how to pass to inputs old value if user fails the laravel validation. I've tried to use:
Example: {{ Request::old('mail') }}
And: {{ old('mail') }}
I think that if user fails laravel validation input values are deleted.
Anyone has some idea to solve the problem?
2 Answers
With laravel 5.2 If you’re redirecting back to the form, a really useful method is withInput():
return redirect()->back()->withInput();
This method has no parameters and what it does is saves the old form values into Session. Then in the form you can use function old($key) to retrieve those values for every field – that would be a separate topic about the Forms.
2 Comments
Martin
Thank you, but tell me please how I can redirect after fail validation? Where to set it? My sign up look like this: pastebin.com/p4qjW1jT. I mean is something in laravel that allows you to redirect after fail laravel validation? For example if(validator == false) or something like that.
Parth Patel
$v = Validator::make($input, $rules); if($v->passes()) { True } else {false}