Manually trigger callbacks on associated models with saveAll()

2009-07-15 Thread Dennis S. Hennen

I have

  ImageSet hasMany Image
  Image actsAs MeioUpload (an upload behavior from the Bakery)

My add form has one ImageSet and 3 Images.

When I $this-ImageSet-saveAll($this-data) in the controller, it
creates the ImageSet and Image records, but the callbacks aren't
called for Image.

I know this is expected -- callbacks on associations do not get called
in Cake 1.2.

The question is: is there a way to get around this limitation and have
the callbacks triggered? I've not thought of a way to do this short of
overloading saveAll() in my ImageSet model.

There is this somewhat related patch from two years ago.
https://trac.cakephp.org/ticket/2056

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



Re: Manually trigger callbacks on associated models with saveAll()

2009-07-15 Thread brian

I've never tried it but this might work:

$this-ImageSet-Image-afterSave($created);

You'd need to sort out whether $created is true or not.

If you wanted to get fancy, you could parse out the models from
$this-data so as to abstract this a bit.


On Wed, Jul 15, 2009 at 4:54 AM, Dennis S.
Hennendennis.hen...@gmail.com wrote:

 I have

  ImageSet hasMany Image
  Image actsAs MeioUpload (an upload behavior from the Bakery)

 My add form has one ImageSet and 3 Images.

 When I $this-ImageSet-saveAll($this-data) in the controller, it
 creates the ImageSet and Image records, but the callbacks aren't
 called for Image.

 I know this is expected -- callbacks on associations do not get called
 in Cake 1.2.

 The question is: is there a way to get around this limitation and have
 the callbacks triggered? I've not thought of a way to do this short of
 overloading saveAll() in my ImageSet model.

 There is this somewhat related patch from two years ago.
 https://trac.cakephp.org/ticket/2056

 Thanks!
 


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