How To Add Attribute To The Owner Model From Behaviour

In my application i want to add additional attribute to the owner model through its behaviours

I have a model to which a behaviour is attached i want to add attributes to that model form the behaviour

How to add additional attributes to the model from the attach($owner) method of behaviour

This is my attach method

//how can i add the code for adding additional attribute to the model

public function attach($owner)

{

$owner->metaData->addRelation( 'gallery', array(CActiveRecord::HAS_ONE, 'Gallery', 'principal_id') );





}


parent::attach($owner);

}

Please make it a bit more elaborate. :rolleyes:

I’m not sure if you can add ‘attributes’ (assume properties). Why not just declare the properties in the model you are declaring the behavior in? (This is what I do).

I should not be difficult since Yii is PHP. I would suggest you read the blog tutorial here is useful link might help you understand better

http://www.yiiframework.com/wiki/167/understanding-virtual-attributes-and-get-set-methods/