How to trigger a controller action in another controller in cakephp?

I want to use "getpoll", which is the action of a user controller, in another controller (event controller).

How can i use it?

thanks in advance ... to everyone ...

+5
source share
4 answers

You should write a db action request getPoll()as a method in the polling model , so in your user controller you can just call $this->User->Poll->getPolls()to capture polls, and if the associations are configured correctly, $this->Event->Poll->getPolls()from your event controller.

For example, in your survey model:

public function getPoll($userId = null) {
    return $this->find('all', array(..));
}
+3
source

requestAction :

$this->requestAction('/comments/latest');

- , :

CookBook:

+4

:

requestAction . . http://book.cakephp.org/2.0/en/controllers.html

And this post a different and better approach

0
source

All Articles