relations.php 1.5 KB
<?php

use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */

$this->title = Yii::t('relation', 'Relations');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="relation-sections">

    <h1><?= Html::encode($this->title) ?></h1>

    <?php
    $dataProvider = new \yii\data\ArrayDataProvider([
        'allModels' => $relations,
        'sort' => [
            'attributes' => ['name', 'key', 'entity1_label', 'entity2_label'],
        ],
        'pagination' => [
            'pageSize' => 10,
        ],
    ]);
    ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'name',
            'key',
            'entity1_label',
            'entity2_label',
            [
                'class' => 'yii\grid\ActionColumn',
                'template' => '{view}',
                'buttons' => [
                    'view' => function ($url, $model) {
                        return Html::a('<span class="glyphicon glyphicon-th-list"></span>', $url, [
                            'title' => Yii::t('relation', 'View pars'),
                        ]);
                    },
                ],
                'urlCreator' => function ($action, $model) {
                    if ($action === 'view') {
                        $url ='/admin/relation/manage/pars?relation='. $model['key'];
                        return $url;
                    }
                }
            ],
        ],
    ]); ?>
</div>