I haven’t been able to find any documentation on this.
Scenario is pretty straightforward - I have a relational model between two tables. The foreign model class defines beforeSave and afterFind functions to handle some data manipulation. When I read write records using the class directly it works fine.
What does not work fine are those behaviors when I try to eager or lazy load the foreign record using the model relationship. So if I do:
$x = Primary::model()->with('foreignTable')->findByPk($primaryPk);
$x = Primary::model()->findByPk($primaryPk); $y = $x->foreignTable;
…the behavior routines defined by the foreign table’s model are never called. I think I understand why the first (eager) load might not work (CActiveFinder?), but I’m not sure why the 2nd wouldn’t.
How can I accomplish this?
edit: I should mention that the relationship between the tables is defined correctly, and the foreign table’s data is loaded ok.