I tried to create a Delete button in CButtonColumn,The problem is when I triggered the delete,It shows me an error Your request is invalid…Can anyone tell me why this is happening…
My controller
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
And my view
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'replay-comment-grid',
'dataProvider'=>$model->search(),
// 'filter'=>$model,
'columns'=>array(
//'id',
//'comment_id',
'admin_replay',
array(
'class' => 'CButtonColumn',
'htmlOptions'=>array('width'=>'180px'),
'template' => '{view}&nbsp;{update}&nbsp;{delete}',
'buttons' => array(
'view'=>array(
'imageUrl' =>false,
'label' => 'View',
'url'=>'Yii::app()->createUrl("replayComment/view/$data->id")',
'options' => array('title'=>'view','class'=>'btn btn-success btn-xs'),
),
'update'=>array(
'imageUrl' =>false,
'label' => '',
'url'=>'Yii::app()->createUrl("replayComment/update/$data->id")',
'options' => array('title'=>'update','class'=>'btn btn-info btn-xs fa fa-pencil-square-o'),
),
'delete'=>array(
'imageUrl' =>false,
'label' => 'delete',
'url'=>'Yii::app()->createUrl("replayComment/delete/$data->id")',
'options' => array('title'=>'delete','class'=>'btn btn-danger btn-xs'),
),
)
),
),
'itemsCssClass'=>'table table-striped table-bordered table-hover',
'pagerCssClass'=>'pagination',
'pager'=>array( 'header' => '','lastPageLabel'=>'<span class="glyphicon glyphicon-chevron-right"></span><span class="glyphicon glyphicon-chevron-right"></span>','firstPageLabel'=>'<span class="glyphicon glyphicon-chevron-left"></span><span class="glyphicon glyphicon-chevron-left"></span>','prevPageLabel'=>'<span class="glyphicon glyphicon-chevron-left"></span>','nextPageLabel'=>'<span class="glyphicon glyphicon-chevron-right"></span>','header' => '','cssFile' => Yii::app()->baseUrl . '/css/pager.css','htmlOptions'=>array('class'=>'pagination'),'selectedPageCssClass'=>'active'),
)); ?>