hey guys, can you help me? i need to pass the $model->value for example in my views to a javascript function. it aint working with registerScript it errors when i pass it inside ex. "var test= $model->value"
Thanks
hey guys, can you help me? i need to pass the $model->value for example in my views to a javascript function. it aint working with registerScript it errors when i pass it inside ex. "var test= $model->value"
Thanks
Dear Friend,
I tested the following code in my localhost.
Kindly check this in your case.
$model=User::model()->find();
$model->username;
Yii::app()->clientScript->registerScript('test',"var name='$model->username';console.log(name)");
I am getting ‘admin’ logged inside the console.
Idea is put the entire script inside the double quotes. php variables inside the single quotes.