1 回答

TA貢獻(xiàn)1841條經(jīng)驗(yàn) 獲得超3個(gè)贊
你可以這樣做:
[
'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()然后在檢查請(qǐng)求的控制器中創(chuàng)建方法post,并對(duì)指定的id. 希望這會(huì)有所幫助。
- 1 回答
- 0 關(guān)注
- 155 瀏覽
添加回答
舉報(bào)