1

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 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
$v = Validator::make($input, $rules); if($v->passes()) { True } else {false}
1

You need to do something like this, if invalid

return Redirect::to('your_ulr')->withInput(Request::all());

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.