2012-05-13 5 views
0

コントローラから他のビューにデータを送信するにはどうすればよいですか?CakePHP 2.x - 他のビューにデータをリダイレクト

function index() 
{ 
    if(!empty($this->data)) 
    { 
       $projects = $this->Hour->getProjectsByDate($this->data); 
       **//here I have to redirect $projects to another view.** 
    } 
    $this->set('projects', $this->Project->find('list', array('conditions' => 
      array('Project.active' => true)))); 
} 

ありがとうございます!あなたの$this->set('projects', $this->Project->find('list', array('conditions' => array('Project.active' => true))));後にこれを追加すること:)

答えて

2

試してみてください。

$this->render('whatever view you want');

はあなたが別のビューをレンダリングする前に、変数を設定することを忘れないでください:

function index() 
{ 
    if(!empty($this->data)) 
    { 
       $projects = $this->Hour->getProjectsByDate($this->data); 
       **//here I have to redirect $projects to another view.** 
        //You should set your variables first before you render a different view: 
       $this->set('projects', $this->Project->find('list', array('conditions' => 
      array('Project.active' => true)))); 

       //Then render a different view 
       $this->render('some other view'); 

    } 

} 
関連する問題