Please help, how i can add dynamic varible in Yii CFormModel?
private function magic($name, $value) {
$this->$name = $value;
}
or
$form = new FormGenerate($attributes);
$form->temp = '1';
Show me Exception "Undetermined property" =(
In your class try something like this
class Test
{
public function __construct($x)
{
$this->{$x} = "dynamic";
}
}
$a = new Test("bar");
print $a->bar;
try changing your
$this->$name
to
$this->{$name}
to see what happens.
I create varible $_params;
And
public function __get($name)
{
if (isset($this->_params[$name])) {
return $this->_params[$name];
}
return parent::__get($name);
}
public function __set($name, $value)
{
if (isset($this->_params[$name])) {
$this->_params[$name] = $value;
} else {
parent::__set($name, $value);
}
}
It's work =)