使用kartik yii2 dynagrid.Am尝试更改动作删除动作列但我收到错误
不允许的方法。此网址只能处理以下请求 方法:POST。
我的代码:
['class' => 'kartik\grid\ActionColumn','dropdown'=>false,
'order'=>DynaGrid::ORDER_FIX_RIGHT,
'template'=>'{delete}',
'buttons'=>[
'delete' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-plus"></span>', $url, [
'title' => Yii::t('yii', 'delete'),
]);
}
]
]
其他操作效果很好,但更改'template'=>'delete'
但只删除操作失败。
答案 0 :(得分:3)
将data-method= "post"
属性包含在您的锚标记
'delete' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-plus"></span>', $url,
[
'title' => Yii::t('yii', 'delete'),
'data-confirm' => "Are you sure you want to delete this item?",
'data-method' => 'post',
'data-pjax' => 0
]);
}