list.php 2.04 KB
<?php
use thread\widgets\grid\ActionCheckboxColumn;
use thread\widgets\grid\GridViewFilter;
//
use backend\modules\map\models\{
    Type, Area
};
use backend\widgets\GridView\gridColumns\ActionColumn;
use backend\widgets\GridView\GridView;

/**
 * @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' => [
        [
            'attribute' => 'title',
            'label' => Yii::t('app', 'Title'),
            'value' => 'lang.title',
        ],
        [
            'attribute' => 'type_id',
            'filter' => GridViewFilter::selectOne($filter, 'type_id', ['0' => '---'] + Type::dropDownList()),
            'value' => function ($model) {
                return $model['typeItem']['lang']['title'];
            },
        ],
        [
            'attribute' => 'area_id',
            'filter' => GridViewFilter::selectOne($filter, 'area_id', ['0' => '---'] + Area::dropDownList()),
            'value' => function ($model) {
                return $model['area']['lang']['title'];
            },
        ],
        /* [
             'attribute' => 'rubric_id',
             'label' => Yii::t($this->context->module->name, 'Rubric'),
             'value' => 'rubric.lang.title',
             'filter' => $model::getRubricDropDownList()

         ],*/
//        [
//            'attribute' => 'type',
//            'value' => function ($model) {
//                return ($this->context->module::typeRange()[$model['type']]) ?? '';
//            },
//            'filter' => $this->context->module::typeRange()
//
//        ],
        // 'position',
        [
            'class' => ActionCheckboxColumn::class,
            'attribute' => 'published',
            'action' => 'published'
        ],
        [
            'class' => ActionColumn::class,
            //'deleteLink' =>  ['id', 'training_id'],
            'updateLink' => ['id', 'type']
        ],
    ]
]);