[Solved] How to create a new relation in behavior


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


                     '_favoris' ,

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



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

Solution override the behavior method attach().

found Solution here :