Exemple #1
0
<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 
if (\Yii::$app->user->can('create-product')) {
    ?>
                    <?php 
    echo Html::a(Yii::t('app', 'Create Product'), ['create'], ['class' => 'btn btn-success']);
    ?>
                <?php 
}
?>
            </p>
            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'emptyText' => 'You don\'t have any products', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'title', 'filter' => AutoComplete::widget(['model' => $searchModel, 'attribute' => 'title', 'options' => ['class' => 'form-control'], 'clientOptions' => ['source' => Product::getAutoCompleteItems('title')]])], ['attribute' => 'ui', 'filter' => AutoComplete::widget(['model' => $searchModel, 'attribute' => 'ui', 'options' => ['class' => 'form-control'], 'clientOptions' => ['source' => Product::getAutoCompleteItems('ui')]])], ['class' => '\\pheme\\grid\\ToggleColumn', 'attribute' => 'active', 'enableAjax' => false, 'filter' => [1 => Yii::t('yii', 'Yes'), 0 => Yii::t('yii', 'No')]], ['class' => 'yii\\grid\\ActionColumn', 'template' => Product::getGridButtonsTemplate(), 'buttons' => ['delete' => function ($url, $model, $key) {
    $options = ['title' => Yii::t('yii', 'Delete'), 'aria-label' => Yii::t('yii', 'Delete'), 'data-confirm' => 'Are you sure you want to delete this item?', 'data-method' => 'post', 'data-pjax' => '0'];
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, $options);
}]]]]);
?>
        </div>
    </div>
</section>