A little bit old but still no answer accepted so...
The answer is no, and yes.
No, there is no direct method since you cannot pass POSTed data using
redirect()
function.
You could userequestAction()
, since you can pass data as posted (see requestAction() here for version cakePHP>=2.0).
In that case you pass an url and then an array having the key data with the posted data, something like
$this->requestAction($url, array('data' =>$this->data));
or if you prefer$this->requestAction($url, array('data' =>$this->request->data));
The problem withrequestAction()
is that the result is environmentally as if you were generating the page of the requested action in the current controller, not in the target, resulting in not very satisfactory effects (at least not usually for me with components behaving not very nicely), so still, no....but Yes, you can do something very similar using the
Session
component.
This is how I usually do it. The flow would be something like this:
View A=>throughpostLink()
to Action in A controller=>
=>A controllerrequest->data
to Session variable=>
=>action in B controller throughredirect()
=>
=>set B controllerrequest->data
from Session variable=>
=>process data in B controller action=> View B
So, in your A controller, let's say in the sentToNewPage()
action you would have something like
//Action in A controller
public function sentToNewPage()
{
$this->Session->write('previousPageInfo', $this->request->data);
$url = array('plugin' => 'your_plugin', 'controller'=>'B',
'action'=>'processFromPreviousPage');
$this->redirect($url);
}
and in B controller:
//Action in B controller
public function beforeFilter()
{//not completelly necessary but handy. You can recover directly the data
//from session in the action
if($this->Session->check('previousPageInfo'))
{$this->data = $this->Session->read('previousPageInfo')};
parent::beforeFilter();
}
public function processFromPreviousPage()
{
//do what ever you want to do. Data will be in $this->data or
// if you like it better in $this->request->data
$this->processUserData($this->request->data);
//...
}