Cakephp: Access data in add function

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-12-24T20:25:13Z Indexed on 2010/12/25 2:54 UTC
Read the original article Hit count: 191

Filed under:

I'm using the CakePHP blog example:

function add() {        
if (!empty($this->data)) {           
 if ($this->Post->saveAll($this->data)) {                
 $this->Session->setFlash('Your post has been saved.');               
  $this->redirect(array('action' => 'index'));            
  }        
}}

I want to modify it in a way that the user is redirected to the post after adding it:

But this doesn't work:

  $this->redirect(array('action' => 'view', $this->Post->id)));    

What is the correct way to read the model's data after creation?

© Stack Overflow or respective owner

Related posts about cakephp