[Solved] Undefined Variable 'data' In Cgridview

Hello,

I get the following error when running the code below:


PHP notice

Undefined variable: data

Here is my code (from my view file)




$this->widget('zii.widgets.grid.CGridView', array(

    'dataProvider'=>$dataProviderUsers,

    'columns'=>array(

        'name',

        'research_interests',

        array(

        	'header'=>'Select a time to meet',

        	'template'=>'{time1}{time2}{time3}',

        	'buttons' => array(

            	'time1' => array(

    			    'label'=>$timeSlots[0],

                    'url' => "Yii::app()->createUrl('/meeting/create', array('id'=>$data->id, 'time'=>'time1'))",

    			),

            	'time2' => array(

    			    'label'=>$timeSlots[1],

    			    'url' => "Yii::app()->createUrl('/meeting/create', array('id'=>$data->id, 'time'=>'time2'))",

    			    'options'=>array( 'class'=>'timeButton'),

    			),

            	'time3' => array(

    			    'label'=>$timeSlots[2],

    			    'url' => "Yii::app()->createUrl('/meeting/create', array('id'=>$data->id, 'time'=>'time3'))",

    			    'options'=>array( 'class'=>'timeButton'),

    			)

        	)

        ),

    ),

    

));



I read the following topic but it did not help me:

http://www.yiiframework.com/forum

Why can’t I used the $data variable in the URL of my custom buttons for my CDataColumn grid column instance?

Thanks.

change all url to this




'url' => 'Yii::app()->createUrl("/meeting/create", array("id"=>$data->id, "time"=>"time1"))',



Thanks teguh11, that did the trick!

I didn’t think switching the double and single quotes would make a difference.

I read just this (from stackoverflow):

… good to know.

This question probably warrants a new thread, but, is there a way I can POST the values instead of sending them through the URL (GET)?

I know I can fill out the ‘click’ property (with a JS function to be invoked when the button is clicked), but I want this to be functional if the user has JS disabled.