$this->title = 'Kategori'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="category-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create Category', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'id', 'format' => 'raw', 'value' => function ($model) { return "#" . $model->id; }], 'nama', 'deskripsi:ntext', ['attribute' => 'parent_category', 'format' => 'raw', 'value' => function ($model) { return $model->parent_category != 0 ? Category::getCateory($model->parent_category)->nama : '-'; }], ['attribute' => 'status', 'format' => 'raw', 'value' => function ($model) { return Category::getStatus($model->status); }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
use backend\assets\CategoryAsset; use backend\models\Category; /* @var $this yii\web\View */ /* @var $model backend\models\Category */ CategoryAsset::register($this); $this->title = $model->nama; $this->params['breadcrumbs'][] = ['label' => 'Categories', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="category-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('Delete', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'nama', 'deskripsi:ntext', ['label' => 'Parent Category', 'value' => $model->parent_category != 0 ? Category::getCateory($model->parent_category)->nama : 'Not Set'], ['label' => 'Status', 'value' => Category::getStatus($model->status)], 'date_create', 'date_update']]); ?> </div>
']); ?> <?php $model->isNewRecord ? $statusField = 'hidden' : (!empty($sub_categorys) ? $statusField = '' : ($statusField = 'hidden')); ?> <div class="subcategory <?php echo $statusField; ?> "> <?php echo $form->field($model, 'sub_category', ['template' => "{label}{input}\n{hint}\n{error}"])->dropDownList($model->isNewRecord ? [] : ArrayHelper::map($sub_categorys, 'id_level2', 'level2'), ['prompt' => '-- Pilih --']); ?> </div> <?php echo $form->field($model, 'status', ['template' => "{label}{input}\n{hint}\n{error}"])->dropDownList(Category::getStatus(), ['prompt' => '-- Pilih --']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>