use yii\grid\GridView; use pendalf89\blog\Module; use pendalf89\blog\helpers\Helper; /* @var $this yii\web\View */ /* @var $searchModel pendalf89\blog\models\TypeSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Module::t('main', 'Post types'); $this->params['breadcrumbs'][] = ['label' => Module::t('main', 'Blog'), 'url' => ['default/index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="type-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Module::t('main', 'New post type'), ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['title', 'alias', ['attribute' => 'show_category', 'format' => 'html', 'value' => function ($model) { return Helper::booleanIconChoiceArray()[$model->show_category]; }, 'filter' => Helper::booleanChoiceArray()], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
use pendalf89\blog\Module; use pendalf89\blog\helpers\Helper; /* @var $this yii\web\View */ /* @var $model pendalf89\blog\models\Type */ $this->title = $model->title; $this->params['breadcrumbs'][] = ['label' => Module::t('main', 'Blog'), 'url' => ['default/index']]; $this->params['breadcrumbs'][] = ['label' => Module::t('main', 'Post types'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="type-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a('<span class="glyphicon glyphicon-pencil"></span> ' . Module::t('main', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('<span class="glyphicon glyphicon-trash"></span> ' . Module::t('main', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'title', 'alias', ['attribute' => 'show_category', 'value' => Helper::booleanChoiceArray()[$model->show_category]]]]); ?> </div>
<div class="type-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'title')->textInput(['maxlength' => 255]); ?> <?php echo $form->field($model, 'alias')->textInput(['maxlength' => 255]); ?> <?php echo $form->field($model, 'show_category')->dropDownList(Helper::booleanChoiceArray()); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Module::t('main', 'Create') : Module::t('main', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>