user1390975
user1390975

Reputation: 104

CakePHP 2.x - redirecting data to other view

How can I send data to other view from controller?

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)))); 
} 

Thank you! :)

Upvotes: 0

Views: 2407

Answers (1)

user1302430
user1302430

Reputation: 352

Try adding this after your $this->set('projects', $this->Project->find('list', array('conditions' => array('Project.active' => true))));:

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

Don't forget to set your variables before you render a different view:

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');

    }

} 

Upvotes: 2

Related Questions