Hi, I’ve just discovered that Yii needs an Object to updated related tables when you save/update the main one. I’ve looked into extensions page where there are:
-
http://www.yiiframework.com/extension/relation/ a widget to update related tables
-
http://www.yiiframework.com/extension/cadvancedarbehavior/ a behavior to do same thing
Now I’d prefer to use a component behavior, but CAdvancedArBehavior has only MANY_MANY capability, it doesn’t work with BELONGS_TO and HAS_ONE, as widget do. Further more, the widget seems a cleaner code.
So I would like to write a behavior taking code from the widget. Now my questions:
-
Does exist a component behavior that makes those update?
-
After I’ve created a behavior and attached to my Active model with:
public function behaviors(){
return array( 'MyBehavior' => array(
'class' => 'path.to.MyBehavior'));
}
How can I access to Behavior’s methods from Controller? I’ve tried $this->MyBehavior->method() but it does nothing
- If I create a method that exists in model where behavior is attached, for example save() method, it overwrites model’s one?