Reputation: 1279
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?
Upvotes: 1
Views: 262
Reputation: 521
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.
Upvotes: 1
Reputation: 34914
You need to do something like this, if invalid
return Redirect::to('your_ulr')->withInput(Request::all());
Upvotes: 1