i have a admin page with CGrideView , but when i want to change my button column to add some other buttons gives this error : CButtonColumn and its behaviors do not have a method or closure named "getId".
admin action :
public function actionAdmin()
{
$model=new Block('search');
$model->unsetAttributes(); // clear any default values
if (isset($_GET['Block'])) {
$model->attributes=$_GET['Block'];
}
$this->render('admin',array(
'model'=>$model,
));
}
admin view :
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'block-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'name',
'content',
'type',
'enable',
array(
'class'=>'CButtonColumn',
'template' => '{view}{update}',
'buttons' => array(
'update' => array(
'url' => 'Yii::app()->controller->createUrl("update", array("name"=>$data->name))'
),
'view' => array(
'url'=>'CController::createUrl("view", array("name"=>$data->name))'
),
),
),
)));
The order of elements in
templatemust be equal to the order of element inbuttons. You have{view}{update}as thetemplate, but you have definedupdatebutton first! So I think changing'template'=>'{view}{update}'into'template'=>'{update}{view}'probably can solve your problem.