model assigns attribute to other model

Hi there,

 I want to assign one model attribute to other model dynamically. How I can do that ?

example :

       $model1 -> $model2 -> Attribute = "String";

Thanks in advance

You could use something like:

$model1->attr = $model2->otherAttr = "String";

To achieve this you should override the setOtherAttr method of $model2 and let it return the value it just set.

Or, for a more generic approach, you could override the __set method something like this:




class Model2 extends CFormModel    // or extend CActiveRecord

{

...

public function __set($prop, $value)

{

[indent]

parent::__set($prop, $value);

return $value;

[/indent]

}

...

}