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
Page 1 of 1
model assigns attribute to other model one model attribute should get assigned to other module
#2
Posted 10 March 2010 - 05:34 AM
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:
$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] } ... }
Share this topic:
Page 1 of 1