OKyJIucT
10/18/2015 - 4:21 PM

GridView

GridView

<?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'title',
            'slug',
            [
                'label' => 'Модерация',
                'format' => 'raw',
                'value' => function ($model) {
                    if ($model->active) {
                        return Html::a('<i class="fa fa-close"></i> ' . Html::encode(Yii::t('app', 'Declined')), Url::to(['declined', 'id' => $model->id]), ['class' => 'btn btn-danger']);
                    } else {
                        return Html::a('<i class="fa fa-check"></i> ' . Html::encode(Yii::t('app', 'Approved')), Url::to(['approved', 'id' => $model->id]), ['class' => 'btn btn-success']);
                    }
                },
            ],
            'text',
            [
                'label' => 'Город',
                'value' => function ($model) {
                    return $model->city->name;
                },
            ],
            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>