Cbuttoncolumn Url

Why is is that I can echo the correct value when echoing $tempSeats but when I try and place the variable in the CButtonColumn ‘url’ field it does not display anything? I have tried numerous solutions to get the variable to show up in the url with no success. Am I missing something easy?


$tempSeats = Yii::app()->getRequest()->getQuery('adult-list');

echo $tempSeats;

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


























        'book' => array


            'label'=>'Book Now',

            'url'=>'$this->grid->controller->createUrl("/bookings/createBooking/flightID/$data->flightID/", array("tempSeats"=>$tempSeats))',





)); ?>


try this

'url'=>'$this->grid->controller->createUrl("/bookings/createBooking/flightID/$data->flightID/", array(\'tempSeats\'=>$tempSeats))'

Thanks for the reply. I am still only seeing /bookings/createBooking/flightID/$data->flightID/tempSeats/

the $tempSeats value is not being placed in the URL still.

This won’t change anything, it just changes double quote to single quote which in PHP it means the same (in this case).

I think the problem is, the OP passed that statement in a string, it should be:

'url' => $this->grid->controller->createUrl("/bookings/createBooking/flightID/$data->flightID/", array('tempSeats'=>$tempSeats))

see I removed the outer quotes?

I removed the outer quotes like suggested and now I receive this error:

Property "FlightsController.grid" is not defined.

Any ideas?

That’s not how createUrl() works. The first parameter is the route (controller/action), the second is an array of GET variables. Try this:

'url'=>'Yii::app()->createUrl("bookings/createBooking", array("flightID"=>$data->flightID, "tempSeats"=>$tempSeats))',

Still empty, I even tried to do $data->tempSeats and it shows zero for every entry. However when I use $data->tempSeats as a column it works fine:


			'header'=>'Temp Seats',




I can’t figure out why it will display correctly in the column but not the URL.

you can try the

"tempSeats" => "{$data->tempSeats}"

'url'=>'Yii::app()->createUrl("bookings/createBooking", array("flightID"=>$data->flightID, "tempSeats" => "{$data->tempSeats}"))',

Still showing zero, this has me stumped.

Ok finally got it to work using:


Thanks for everyones help.