0

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 definedbut actual value of $approval should be 1. What does this mean and how can I solve this.

Rudra
  • 711
  • 7
  • 13
  • 31

2 Answers2

0

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);
          }
      )
  ),
Ninad
  • 1,871
  • 3
  • 15
  • 23
  • I can get teh value of $approved in admin.php. But, when I pass it to another view file it is undefined – Rudra Aug 12 '13 at 11:55
  • 'url' => 'Yii::app()->controller->createUrl("/testSettings/update", array("id"=>$data->Id,"approval"=>$approval))', Here $approval value was 0 – Rudra Aug 12 '13 at 11:59
  • Wher is the view file mentioned in it ?? – Ninad Aug 12 '13 at 12:00
  • I need to use $approved value in _form.php. How can I do – Rudra Aug 12 '13 at 12:03
  • Pls tell me how I can do – Rudra Aug 12 '13 at 12:03
  • How can I pass from widget in admin.php – Rudra Aug 12 '13 at 12:10
  • Maybe, you didn't fetch the variable in update.php? $approval = Yii::app()->request->getParam('approval'); Or in the controller: public function actionUpdate($id, $approval) (then you need to send it to your view by passing it in your render-function.) – ippi Aug 13 '13 at 01:38
0

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
}
Cherif BOUCHELAGHEM
  • 1,126
  • 2
  • 14
  • 21