I have a variable in admin.php .i.e $approved
. This is got by the value of a radiobutton using this code.
$approval = Yii::app()->request->getParam('approval',"0");
Now, I need to pass this variable from admin page to update page. For which I have written the following lines
array(
'class'=>'CButtonColumn',
'template'=>'{update}',
'buttons' => array(
'view' => array (
'url' => 'Yii::app()->controller->createUrl("/testSettings/update", array("id"=>$data->Id,"approval"->$approval))',
),
),
I'm not able to retrieve the value of $approved in _form.php. But, when I gave echo $approved,PHP notice is displayed saying $approved not defined
but actual value of $approval should be 1. What does this mean and how can I solve this.
UPDATED
You can pass that value to _form as shown
$this->renderPartial('_form',array('approval'=>$approval);
You can pass as a value param as shown
'columns'=>array(
array(
'name'=>'yorName',
'value'=>function($data, $row) use ($controller){
return $controller->renderPartial('_form', array('approved'=>$approved), true);
}
)
),
Use Yii::app()->createUrl
or in the view you can use the controller context with this
keyword the solution: in the admin view:
array(
'class'=>'CButtonColumn',
'template'=>'{update}',
'buttons' => array(
'view' => array (
'url' => 'Yii::app()->createUrl("/testSettings/update", array("id"=>$data->Id,"approval"=>$approval))',
),
),
in the controller update action you have to pass approval as paramter ($_GET):
public function actionUpdate($id,$approval){
//your code here
}