0

I'm having trouble passing form data from one view to another, I don't want to validate the data and insert it into the database. I just need the data so I can insert it into a larger form.

I tried redirecting my post model with the variables from the first part of the form to the full form so I can display the data from the first form.

public function postQuote(Request $request)
{
    $fromDest = $request->input('from-dest');
    $toDest = $request->input('to-dest');


    return redirect('/quote')->with('fromDest', $fromDest)
        ->with('toDest', $fromDest);
}

But the variable doesn't pass. Is there any other method I can use to simply just pass the data onto another page?

I'm pretty new to Laravel, mostly used to the traditional ways of dealing with forms.

6
  • this is done with a session, you need to save the request to a session and then continue to another page Commented Apr 3, 2017 at 20:10
  • Please show us how you are trying to retrieve the variables on the other page. Commented Apr 3, 2017 at 20:12
  • @dparoli {{ $fromDest }} <-- Essentially like this Commented Apr 3, 2017 at 20:17
  • @lewis4u Really? Thought it would be simpler than that, thanks for clearing it up though. Commented Apr 3, 2017 at 20:17
  • its a redirect, the with() passes the variables in the session. You have to retrieve them with session('fromDest') Commented Apr 3, 2017 at 20:20

1 Answer 1

1

You must store data in session to use it in the next request

See the docs Flash Data

i hope this will help you.

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

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.