0

I'm setting data to another_view action using following process. But I can't get the sending data.

$this->autoRender = false; 
$dis = new Dispatcher(); 
$dis->dispatch( 
    array("controller" => "users", "action" => "another_view"), 
    array("data" => $user) 
);  

How can I get this $user data from another_view? please help, thanks.

thecodeparadox
  • 86,271
  • 21
  • 138
  • 164

1 Answers1

0

how about creating a function that both methods could call and pass the data as a parameter.

class Users extends AppController{

   function another_view(){
       ...
       $this->_myFunction($this->data);
   }

   function _myFunction($data = array()){
       ... //do something with the data
   }
}

class AnotherModel extends AppController{
   function index(){
      App::import('Controller', 'Users');
      $Users = new UsersController;
      $Users->constructClasses();
      $Users->_myFunction($myData);
   }
}

However.. it's better if you put it in the model (if possible)

Hope this helps

Community
  • 1
  • 1
pleasedontbelong
  • 19,542
  • 12
  • 53
  • 77