CakePHP: Passing $this->params['form'] in a requestAction call?
-
25-05-2021 - |
Question
How can I pass $this->params['form']
to the controller action I specify in requestAction
so that I can use the variable in the same way by calling $this->params['form']
?
Here is what I'm trying (but isn't working):
$this->requestAction('/reports/grid', array('params["form"]' => $this->params['form']));
$this->requestAction('/reports/grid', array('$this->params["form"]' => $this->params['form']));
Solution
$this->requestAction('/reports/grid', array('form' => $this->params['form']));
OTHER TIPS
According to the 1.3 documentation, you'll need to specify each parameter you want to send off in the request in the pass
or named
parameter key - http://book.cakephp.org/1.3/en/view/991/requestAction
echo $this->requestAction(array('controller' => 'articles', 'action' => 'featured'), array('named' => array('limit' => 3)));
echo $this->requestAction(array('controller' => 'articles', 'action' => 'view'), array('pass' => array(5)));
So, it should be something like
$this->requestAction('/reports/grid', array('pass' => array($this->params['form'])));
Note - There are very few good reasons you would want to use requestAction
. Please read up on the performance penalties if you haven't already.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow