Yii Framework Forum: How To Add Attribute To The Owner Model From Behaviour - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Add Attribute To The Owner Model From Behaviour Rate Topic: -----

#1 User is offline   manas ranjan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 07-September 12

Posted 02 January 2013 - 05:06 AM

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);
}
0

#2 User is offline   YearningForYii 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 63
  • Joined: 21-September 12

Posted 02 January 2013 - 07:02 AM

Please make it a bit more elaborate. :rolleyes:


View Postmanas ranjan, on 02 January 2013 - 05:06 AM, said:

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

0

#3 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 357
  • Joined: 23-July 09

Posted 02 January 2013 - 11:02 AM

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).
We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#4 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 677
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 02 January 2013 - 11:37 AM

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.yiiframew...et-set-methods/
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users