list.php 1.58 KB
<?php
use yii\helpers\Html;
use thread\widgets\grid\ActionCheckboxColumn;
use backend\widgets\GridView\GridView;
use backend\widgets\GridView\gridColumns\ActionColumn;

/**
 * @var \backend\modules\map\models\Item $model
 */

echo GridView::widget([
    'dataProvider' => $model->search(Yii::$app->request->queryParams),
    'tableOptions' => ['class' => 'table table-striped table-bordered'],
    'filterModel' => $filter,
    'columns' => [
        [
            'format' => 'raw',
            'attribute' => 'image_link',
            'value' => function ($model) {
                return Html::img($model->getImageLink(), ['alt' => ($model->lang) ? $model->lang->title : '', 'style' => 'width:50px;']);
            },
        ],
        [
            'format' => 'raw',
            'attribute' => 'title',
            'label' => Yii::t('app', 'Title'),
            'value' => function ($model) {
                return ($model->lang) ? $model->lang->title : 'Не задано';
            },
        ],
        [
            'attribute' => 'type_map',
            'value' => function ($model) {
                return ($this->context->module::typeRange()[$model['type_map']]) ?? '';
            },
            'filter' => $this->context->module::typeRange()

        ],
        'position',
        [
            'class' => ActionCheckboxColumn::class,
            'attribute' => 'published',
            'action' => 'published'
        ],
        [
            'class' => ActionColumn::class,
            //'deleteLink' =>  ['id', 'training_id'],
            'updateLink' => ['id', 'type_map']
        ],
    ]
]);