[SOLVED] I Can't get $data->id to work in CButtonColumn

I must be doing something wrong, I needed to add pid to the update button within CButtonColumn but when I did this it removed the row id of the active record so I added id with ‘id’=>’$data->id’ but it doesn’t output the id.

Does anybody know where I’m going wrong?




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

	'id'=>'issue-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'id',

		'name',

		'description',

		'project_id',

		'type_id',

		'status_id',

		/*

		'owner_id',

		'requester_id',

		'create_time',

		'create_user_id',

		'update_time',

		'update_user_id',

		*/

		array(

			'class'=>'CButtonColumn',

			'updateButtonUrl'=>"Yii::app()->createUrl('issue/update', array('id'=>'$data->id', 'pid'=>'$model->project_id'))",

			)

		),

	)

);



Try this

createUrl(‘issue/update’, array(‘id’=>’$data->id’), ‘&pid=$model->project_id’)

Thanks Thirumalai, but it’s still only showing the pid and not the id of the row.

Can you see anything obvious I’m missing?

[SOLVED]

The problem was caused because I was trying to access pid through $model when I should have been accessing it through $data as $model had been passed to the widget. See code below.




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

	'id'=>'issue-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'id',

		'name',

		'description',

		'project_id',

		'type_id',

		'status_id',

		array(

			'class'=>'CButtonColumn',

			'updateButtonUrl'=>'Yii::app()->controller->createUrl("update",array("id"=>$data->primaryKey, "pid"=>$data->project_id))'

			),

		),

	)

);

?>