[Solved] How to create a new relation in behavior

Hi,

I have a model (UserBase) + a behaviors (FavorisBehavior)

I attach the behavior to the model using behaviors(). So model now has behavior’s method.

Now I’d like to had the behavior to add a relation to the model. But I failled.

How can a behavior define a new relation in the model it is attached ?


New relation code is




$this->owner->metaData->addRelation(

                     '_favoris' ,

                    array(self::HAS_MANY, 'Favoris', 'creation_user') 

            );

$this->owner->refreshMetaData();



This only thing I was missing was where to create that relation.

Solution override the behavior method attach().

found Solution here :

http://www.yiiframework.com/forum/index.php/topic/1039-creating-relations-from-a-behavior/

http://www.yiiframework.com/forum/index.php/topic/30380-dynamically-add-relations-to-model/