I have noticed this behavior as well. It's because in Model::saveAll, the call to Model::save uses this- >data[$this->alias] instead of $this->data. therefore if you have a data array that looks like array( 'Model1' => array(data) 'Model2' => array(data) )
and you call Model1->saveAll, guess what? Model2 doesn't get saved if it's a habtm relation. there is a ticket already opened in the bug tracker https://trac.cakephp.org/ticket/4389 i'll be watching that ticket for updates and until then banging my head against the wall. On Apr 3, 10:16 am, avairet <[EMAIL PROTECTED]> wrote: > Hi, > > I'm using nightly builds from 1.2.x.x branch. > > My main model Item have this associations: > Item hasOne Article > Item hasOne Photo > Item hasAndBelongsToMany Tag > ... > > In a form I have these fields : > data['Item']['id'] (it's results on a form input TEXT) > data['Item']['title'] (it's results on a form input TEXT) > data['Article']['legend'] (it's results on a form input TEXT) > data['Photo']['credits'] (it's results on a form input TEXT) > data['Tag']['Tag'] (it's results on a form SELECT multiple) > > Apparently, the Model::saveAll() method does not save the HABTM, even > this method call itself the save() method... > > At this point I make a $this->Item->save($this->data) and after a > $this->Item->saveAll($this->data). > That's works fine but problems occur when I want validate and display > error... > > So how can I save all fields in one call and manage correctly > validations and error messages? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---
