YII2 少用的一些扩展 插件等功能 自定义操作按钮

[
'attribute' => 'status',
'label' => '状态',
'value' => function ($model) {
return $model->status == 1 ? '开启' : '关闭';
},
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{close}',
'buttons' => [
// 自定义按钮

'close' =>
function ($url, $model, $key) {
$options = [
'title' => '显示',
'aria-label' => '显示',
'data-pjax' => '0',
];
return Html::a($model->status == 1 ? '关闭' : '开启', $url, $options);
},
]
],
close 就是当前控制器对应 方法名

猜你喜欢

转载自www.cnblogs.com/lchg/p/9075197.html