Post->recursive = 0; $this->set('posts', $this->paginate()); } function add() { if(!empty($this->data)) { $this->cleanUpFields(); $this->Post->create(); if($this->Post->save($this->data)) { $this->Session->setFlash('The Post has been saved'); $this->redirect(array('action'=>'index'), null, true); } else { $this->Session->setFlash('The Post could not be saved. Please, try again.'); } } } function edit($id = null) { if(!$id && empty($this->data)) { $this->Session->setFlash('Invalid Post'); $this->redirect(array('action'=>'index'), null, true); } if(!empty($this->data)) { $this->cleanUpFields(); if($this->Post->save($this->data)) { $this->Session->setFlash('The Post saved'); $this->redirect(array('action'=>'index'), null, true); } else { $this->Session->setFlash('The Post could not be saved. Please, try again.'); } } if(empty($this->data)) { $this->data = $this->Post->read(null, $id); } } } ?>