The call to parent::afterSave() will fire the ‘OnAfterSave’ event which in turn will trigger the behavior’s afterSave method. So you can control it, by putting that call a little after what you want to do first.
Not sure, if that’s what you asked though - it’s not related to relations.
Hmm. Are you sure? If you look at the source of CActiveRecordsBehavior.php you’ll note, that afterSave() doesn’t do anything. In fact, you should not need to call parent::afterSave() in your behavior at all.
But it’s important that you call it in your model’s afterSave(). Can you please verify: Comment out the call to parent::afterSave() in your model and check wether your behavior’s afterSave() gets still called? It should not!
if i remove the aftersave in the model the behavior isn’t called.
Hmm thats strange, because i sent a email with some data from an relation of my model.
In my case the authors of the dissemination.
The authors of the edit / insert form are processed in the processAuthors() method.
I guess my problem is that the relation isn’t queried again.
I do show the insert / update form where the dissemination fields are filled and also saved. On the form there is also an authors list which the users can add. This authors are saved in processAuthors().
And in the behavior afterSave() I use the model fields and th relation ‘authors’ to fill an email with the data.
In the email the newer data of the model is set, but the relation shows the old state which was shown when the form was loaded. And doesn’t show the changed relations.
Is there something to ‘refresh’ the relation (query again?) after processAuthors() ?
this can be currently only avoided through in afterSave().
// refresh the relations used to have the updated data in the relations.