Cakephp: Access data in add function
- by Chris
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?