Hi Aaron, I re-read my old messages... My data array seems to look like your example... But neither Model1->saveAll() or Model2->saveAll() seems to work!
In my case and standing for Model::saveAll() enhancement or new function, I make a Model1->save($this->data) which save my main model and its HABTM and in my Controller::afterSave() method, I do: unset(this->data[MyModel1]), unset(this->data[MyHABTM1])... Then I call a custom action named "saveOthers()" with the $this->data array updated! That work very fine and avoid a lot of queries due to save() + saveAll(). But it seems the error validation messages are not displayed when saveOthers() fail... On 8 avr, 22:41, aaron bauman <[EMAIL PROTECTED]> wrote: > 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 > trackerhttps://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 "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 -~----------~----~----~----~------~----~------~--~---
