Use the following format code to make custom action button in Gridview:
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Actions',
'headerOptions' => ['style' => 'color:#337ab7'],
'template' => "{update} {print} {delete}",
'buttons' => [
'view' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, [
'title' => Yii::t('app', 'lead-view'),
]);
},
'update' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
'title' => Yii::t('app', 'lead-update'),
]);
},
'delete' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
'title' => Yii::t('app', 'lead-delete'),
'data' => [
'confirm' => 'Anda yakin ingin menghapus data?',
],
]);
},
'print' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-print"></span>', $url, [
'title' => Yii::t('app', 'lead-print'),
]);
},
],
'urlCreator' => function ($action, $model, $key, $index) {
if ($action === 'update') {
$url ='index.php?r=contohuji/update&id_daftar='.Yii::$app->request->get("id")."&id=".$model->id_contohuji;
return $url;
}
if ($action === 'delete') {
$url ='index.php?r=contohuji/delete&id_daftar='.Yii::$app->request->get("id")."&id=".$model->id_contohuji;
return $url;
}
if ($action === 'print') {
$url ='index.php?r=contohuji/print&id_daftar='.Yii::$app->request->get("id")."&id=".$model->id_contohuji;
return $url;
}
}
],