| |
ArqHP - Arquitetura de home pages |
Pessoal, Estou fazendo uma galeria com o cake, e o que me ocorre é o seguinte, quando vou editar uma galeria, ao clicar em update, ele me faz um insert ao invez do update, olhem o action dentro do controller galleries_controller.php function admin_edit($id = null) { <?php //The Associations below have been created with all possible keys, those that are not needed can be removed var $belongsTo = array( 'User' => array('className' => 'User', 'foreignKey' => 'user_id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); var $hasAndBelongsToMany = array( 'Category' => array('className' => 'Category', 'joinTable' => 'categories_galleries', 'foreignKey' => 'gallery_id', 'associationForeignKey' => 'category_id', 'unique' => true, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderQuery' => '', 'deleteQuery' => '', 'insertQuery' => '' ), 'Package' => array('className' => 'Package', 'joinTable' => 'galleries_packages', 'foreignKey' => 'gallery_id', 'associationForeignKey' => 'package_id', 'unique' => true, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderQuery' => '', 'deleteQuery' => '', 'insertQuery' => '' ) ); João Vagner 011 8923-9648
$this->layout='admin';
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid Gallery', true));
$this->redirect(array('action'=>'index'));
if ($this->Gallery->save($this->data)) {
$this->Session->setFlash(__('The Gallery has been saved', true));
$this->redirect(array('action'=>'index'));
}
$this->data = $this->Gallery->read(null, $id);
$packages = $this->Package->find('list', array('fields'=>array('Package.id', 'Package.titulo'), 'value'=>'Package.id'));
$this->set(compact('categories', 'packages'));
class Gallery extends AppModel {
var $name = 'Gallery';
j...@iw2.com.br
www.iw2servers.com.br
#IW² blog [ http://iw2servers.com.br/blog ]