Supported button options: - label: string - button label. - encode: boolean - whether to encode label. - icon: string - button icon short name. - options: array - link tag HTML options. - visible: boolean|callable - whether button should be rendered or not. - url: callable - callback, which should return button URL. This widget also provides default buttons as configuration, which will be merged with [[buttons]] recursively.
Since: 1.0
Author: Paul Klimov (klimov.paul@gmail.com)
Inheritance: extends yii\grid\ActionColumn
 /** @inheritdoc */
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     $this->buttons['edit'] = $this->buttons['update'];
     unset($this->buttons['update']);
     $this->buttons['view']['options'] = ['target' => '_blank'];
     array_walk($this->buttons, function (&$item) {
         $item['options'] = ArrayHelper::merge($item['options'], ['class' => 'btn btn-default btn-sm']);
     });
 }
Example #2
0
$controller = $this->context;
$contextUrlParams = $controller->getContextQueryParams();
$this->title = Yii::t('admin', 'Administrator Auth Logs');
foreach ($controller->getContextModels() as $name => $contextModel) {
    $this->params['breadcrumbs'][] = ['label' => Yii::t('admin', 'Administrators'), 'url' => $controller->getContextUrl($name)];
    $this->params['breadcrumbs'][] = ['label' => $contextModel->username, 'url' => $controller->getContextModelUrl($name)];
}
$this->params['breadcrumbs'][] = $this->title;
$authErrorLabels = $searchModel->authErrorLabels();
?>

<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'rowOptions' => function ($model, $key, $index, $grid) {
    /* @var $model AdminAuthLog */
    if ($model->error === null) {
        return ['class' => 'success'];
    } else {
        return ['class' => 'danger'];
    }
}, 'columns' => ['id', ['attribute' => 'date', 'format' => 'datetime'], ['attribute' => 'cookieBased', 'format' => 'boolean', 'filter' => ['1' => Yii::t('yii', 'Yes'), '0' => Yii::t('yii', 'No')]], 'duration', ['attribute' => 'error', 'filter' => array_merge(['-' => '-'], $authErrorLabels), 'value' => function ($model) use($authErrorLabels) {
    if ($model->error === null) {
        return '-';
    }
    if (isset($authErrorLabels[$model->error])) {
        return $authErrorLabels[$model->error];
    }
    return $model->error;
}], 'ip', 'host', 'url:url', 'userAgent', ['attribute' => 'username', 'header' => $searchModel->getAttributeLabel('username'), 'format' => 'raw', 'value' => function ($model) {
    return Html::a(Html::encode($model->admin->username), ['/admin/view', 'id' => $model->admin->id]);
}, 'visible' => !$controller->isContextActive('admin')], ['class' => ActionColumn::className(), 'template' => '{view}']]]);
Example #3
0
<?php

use app\models\filedb\IdentityStatus;
use yii\grid\GridView;
use yii2tech\admin\grid\ActionColumn;
use yii\helpers\ArrayHelper;
use yii2tech\admin\grid\DeleteStatusColumn;
/* @var $this yii\web\View */
/* @var $searchModel app\models\backend\AdminSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('admin', 'Administrators');
$this->params['breadcrumbs'][] = $this->title;
$this->params['contextMenuItems'] = [['create']];
?>

<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', 'username', 'email:email', ['class' => DeleteStatusColumn::className(), 'attribute' => 'statusId', 'filter' => ArrayHelper::map(IdentityStatus::find()->all(), 'id', 'name'), 'value' => function ($data) {
    return $data->status->name;
}], ['attribute' => 'createdAt', 'format' => 'date', 'filter' => false], ['class' => ActionColumn::className()]]]);