Exemple #1
0
$this->title = Yii::t('app', 'Categories');
$this->params['breadcrumbs'][] = $this->title;
?>

<section class="content">
    <?php 
echo \common\widgets\Alert::widget();
?>
    <div class="box box-primary">
        <div class="box-body">
            <h1><?php 
echo Html::encode($this->title);
?>
</h1>

            <p>
                <?php 
echo Html::a(Yii::t('app', 'Create Category'), ['create'], ['class' => 'btn btn-success']);
?>
            </p>

            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'emptyText' => 'You don\'t have any categories', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'title', 'filter' => AutoComplete::widget(['model' => $searchModel, 'attribute' => 'title', 'options' => ['class' => 'form-control'], 'clientOptions' => ['source' => Category::getAutoCompleteItems('title')]])], ['class' => '\\pheme\\grid\\ToggleColumn', 'attribute' => 'active', 'enableAjax' => false, 'filter' => [1 => Yii::t('yii', 'Yes'), 0 => Yii::t('yii', 'No')]], ['class' => 'yii\\grid\\ActionColumn', 'template' => Category::getGridButtonsTemplate(), 'buttons' => ['delete' => function ($url, $model, $key) {
    $options = ['title' => Yii::t('yii', 'Delete'), 'aria-label' => Yii::t('yii', 'Delete'), 'data-confirm' => !$model->isUse() ? 'Are you sure you want to delete this item?' : 'Warning! This category is used in other places! Category will be soft deleted!', 'data-method' => 'post', 'data-pjax' => '0'];
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', !$model->isUse() ? Url::toRoute(['category/delete', 'id' => $model->id]) : Url::toRoute(['category/soft-delete', 'id' => $model->id]), $options);
}]]]]);
?>
        </div>
    </div>
</section>