我试图在索引中创建自定义操作列并编写此代码:
[
'class' => 'yii\grid\ActionColumn',
'contentOptions' => ['style' => 'width:50px;'],
'header'=>'',
'template' => '{view} {update}',
'buttons' =>
[
//view button
'view' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, [
'title' => Yii::t('app', 'View'),
]);
},
'update' => function ($url, $model) {
if (Yii::$app->user->can('change-offer'))
{
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
'title' => Yii::t('app', 'Update'),
]);
}
},
'delete' => function ($url, $model) {
if (Yii::$app->user->can('delete-offer'))
{
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
'title' => Yii::t('app', 'Delete'),
'data-confirm' …Run Code Online (Sandbox Code Playgroud)