| |
ArqHP - Arquitetura de home pages |
Concordo com o Danilo. Sem querer ser chato, mas voce poderia dar uma otimizada nesse código né? function admin_edit($id = null) { if (!empty($this->data)) { $this->data = $this->Gallery->read(null, $id); $categories =
Ve se você não está esquecendo um input hidden com name="data[Gallery][id]"
Voce tem que colocar o id do registro que voce queira dar o update dentro
deste input.
Talvez usar isso:
$this->layout='admin';
if ($this->Gallery->save($this->data)) {
$this->Session->setFlash(__('The Gallery has been saved',
true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The Gallery could not be saved.
Please, try again.', true));
}
} else {
if (!$id) {
$this->Session->setFlash(__('Invalid Gallery', true));
$this->redirect(array('action'=>'index'));
}
}
$this->Gallery->Category->find('list',array('fields'=>array('Category.id',
'Category.titulo'), 'value'=>'Category.id'));
$packages = $this->Package->find('list',
array('fields'=>array('Package.id', 'Package.titulo'),
'value'=>'Package.id'));
$this->set(compact('categories', 'packages'));
nos arrays.
Ficaria mais legível.