Jilco Tigchelaar
Jilco Tigchelaar

Reputation: 2187

Zend framework 2 toroute pass variable to next controller

After a succes form i want to redirect to another controller, i do that with toRoute. Below there is an example

return $this->redirect()->toRoute('plaatsenrubriek',array('controller'=>'AdvertentieController', 'action'=>'plaatsenrubriek'));

Is there a way to insert a variable in the toRoute to pass to the next controller?

Upvotes: 0

Views: 158

Answers (1)

Ankh
Ankh

Reputation: 5728

The only way to pass a variable during a redirect would be to add a query parameter to the target route.

$bar = 'bar';

$this->redirect()->toRoute('myRoute', array(), array(
    'query' => array(
        'foo' => $bar,
    )
));

Which would result in /myRoute?foo=bar

Upvotes: 1

Related Questions