Reputation: 16966
I am trying to pass parameters from one action (foo) to another (foobar).
In action foo, I set the arguments thus:
$request->getParameterHolder()->set('arg1', 'alice');
$request->getParameterHolder()->set('arg2', 'bob');
In action foobar, I try to retrieve the params thus:
$arg1 = $request->getParameter('arg1');
$arg2 = $request->getParameter('arg2');
$this->forward404Unless($arg1 && $arg2); //always forwarded
Note: I am aware that I can save the params into the user session variable - but I dont want to do that. I want to pass them as parameters - any ideas how to get this to work?
Upvotes: 1
Views: 185
Reputation: 1721
greg0ire's answer sounds like it's what you are asking for but there are a couple of other approaches that might be worth looking at if passing query string parameters isn't a hard requirement.
You could use a forward if you want the foobar action to execute after foo. Unlike a redirect this will live in the same request cycle so you can pass variables without touching the session.
You don't say why you don't want to use the session but there is a halfway house in Symfony: flash attributes. These are stored in the session but are guaranteed not to live beyond the next request which may be a suitable compromise.
Upvotes: 1
Reputation: 23255
You can simply try this:
$this->redirect('module/action2?'.
http_build_query(array("arg1"=> "alice", "arg2"=>"bob")));
Upvotes: 2