Hello!
There is a problem with delete button - 400 error. Again)
I see three ways to solve it:
-
Find the problem in my code
-
Create my own cbuttoncolumn-mega-delete-button
-
Use it without ‘postonly’ filter
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('role'=>'administrator'));
}
config/main:
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
view:
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'itemGrid',
'ajaxVar'=> true,
'ajaxUpdate'=> true,
'summaryText'=>'',
'enableSorting'=>false,
'itemsCssClass'=>'table table-bordered table-striped table-hover',
'htmlOptions'=>array(
'style'=>'width: 100%;',
),
'dataProvider' => $dataProvider,
'columns'=>array(
array(
'htmlOptions'=>array(
'style'=>'text-align:center;',
),
'name' => 'id',
'header'=>'ID',
'value' => '$data->id'
),
...(other tables)
array(
'header'=>'Functions',
'class'=>'CButtonColumn',
'viewButtonImageUrl'=>'',
'viewButtonLabel'=>'View',
'viewButtonOptions'=>array(
'class'=>'icon-ok',
),
'updateButtonImageUrl'=>'',
'updateButtonLabel'=>'Change',
'updateButtonOptions'=>array(
'class'=>'icon-pencil'
),
'deleteButtonImageUrl'=>'',
'deleteButtonLabel'=>'Delete',
'deleteButtonOptions'=>array(
'class'=>'icon-trash'
)
),
),
));
?>
-
There is an idea to create my own button, but how to make it as ajax type?
-
most unwanted way, but it works…