function edit($id = null, $summary_id = null) { if(!$id && empty($this->data)) { $this->Session->setFlash('Invalid Article'); $this->redirect(array('action'=>'index'), null, true); } if(!empty($this->data)) { print_r($this->data); $this->Article->id = $id; $this->data['Summary']['article_id'] = $id; $this->Article->Summary->id = $summary_id; if($this->Article->save($this->data)) { if($this->Article->Summary->save($this->data)) { $this->Session->setFlash('Article saved'); $this->redirect('/articles/view/'.$id, null, true); } else { $this->Session->setFlash('The abstract could not be saved. Please, try again.'); } } else { $this->Session->setFlash('The Article could not be saved. Please, try again.'); } } if(empty($this->data)) { $this->cleanUpFields(); $this->data = $this->Article->read(null, $id); $this->set('summary_id', $summary_id); } }