Hi, I'm filling a form with a select control, when I choose an option from
that select, an ajax request is made and if there is data from that store,
several text box are filled with the store's data. If there is no data for
that store, the user can fill the text boxes and then the data is save. So
far so good. The problem is when I try to "update" the info. I read the docs
and tried to $mymodel->id = store_id_to_update but without look. Debugging
always show a sql insert statement and not an update statement. So I do a
del() first and then a save() call. The problem is that now, I'm using mysql
foreign key constraint so I can't del() because of data integrity. Any help?
my code looks like:

if(!empty($this->params['form'])) {
       $conditions = array('AdministradorConsumos.id' =>
$this->params['form']['id_consumo']);
       $existe = $this->AdministradorConsumos->find('all',
array('conditions' => $conditions));
       if(sizeof($existe) > 0) {
             $this->AdministradorConsumos->id =
$existe['AdministradorConsumos']['id'];
             $this->id = $existe['AdministradorConsumos']['id'];
             $this->params['form']['id'] =
$existe['AdministradorConsumos']['id'];
       }

//$this->AdministradorConsumos->del($this->params['form']['id_consumo']);
       if($this->AdministradorConsumos->save(array('AdministradorConsumos'
=> $this->params['form']), false)) {
             $this->flash('Success', '/administrador_consumos/add');
       }
}

I'm using the dojo toolkit for user interface, so i'm not using the html
helper, so I need to use $this->params['form'] to get data. Any clue? Thanks
in advance!

-- 
Mauricio Tellez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to