Alphal's avatar

Laravel save datas after return redirect back with error

Hi guys I am a beginner in laravel.

I have a form with 10 inputs. I have this case: When form is submitted and something goes wrong I redirect it back to the previous page, but what I see is that all datas are gone. I have to fill the form from again and again.

What should I do in this case? Please help mee

0 likes
6 replies
Alphal's avatar

@JLRDW - I did that but nothing happend. Should I add something at controller when I redirect it back?

jlrdw's avatar

Just follow the documentation it should work. Make sure you set up your validation.

Cronix's avatar

Show the controller the form submits to and the view with the form. We don't know how you've set everything up from our side of the screen, and there are several ways to do it.

tykus's avatar

If you are manually redirecting back, then you will need to redirect withInput() to put the old values in the session of the old() helper to work.

return back()->withInput();

A validation failure will handle old input and redirection automatically.

Please or to participate in this conversation.