1 回答
TA贡献1841条经验 获得超3个赞
你可以这样做:
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {delete} {made}',
'buttons'=> [
...
'made' => function ($url, $model) {
if($model->status === $model::STATUS_SUSPENDED){
return Html::a("Activate", $url, [
'title' => "Activate",
'class' => 'btn btn-xs btn-success',
'data' => [
'method' => 'post',
'confirm' => 'Are you sure? This will Activate this.',
],
]);
}
return Html::a("Suspend", $url, [
'title' => "Suspend",
'class' => 'btn btn-xs btn-danger',
'data' => [
'method' => 'post',
'confirm' => 'Are you sure? This will Suspend this.',
],
]);
}
],
]
actionMade()然后在检查请求的控制器中创建方法post,并对指定的id. 希望这会有所帮助。
- 1 回答
- 0 关注
- 121 浏览
添加回答
举报