/** * @return \yii\db\ActiveQuery */ public function getCategories() { return $this->hasMany(NewsCategory::className(), ['id' => 'category_id'])->viaTable('{{%news_news_category}}', ['news_id' => 'id']); }
?> <?php echo $form->field($model, 'date')->dateTimeInput(['class' => 'pull-right']); ?> <?php echo $form->field($model, 'status')->dropDownList($model->getStatusesList()); ?> <?php echo $form->field($model, 'category_id')->dropDownList($modelCategory->getItemsForLinkedField(), ['encodeSpaces' => true]); ?> <?php echo $form->field($model, 'categories')->treeInput(['class' => NewsCategory::className()]); ?> <?php echo $form->field($model, 'description')->widget(LangInputWidget::classname(), ['options' => ['type' => 'activeTextarea']]); ?> <?php echo $form->field($model, 'content')->widget(LangInputWidget::classname(), ['options' => ['type' => 'activeTextarea', 'redactor' => true, 'urlPreffix' => 'news/', 'form' => $form]]); ?> </div> <div class="tab-pane" id="tags-tab"> <? $modalNewTag = Modal::widget([ 'id' => 'new-tag-modal', 'toggleButton' => [
public function actions() { return ['get-level-data' => ['class' => actionGetLevelData::className(), 'modelClass' => NewsCategory::className()], 'move-item' => ['class' => actionMoveItem::className(), 'modelClass' => NewsCategory::className()]]; }
echo JSTreeWidget::widget(); ?> </div> <div class="col-md-9"> <p> <?php echo Html::a(Yii::t('b/news/category', 'Create News Category'), ['create', 'parent_id' => $parent_id], ['class' => 'btn btn-success']); ?> </p> <?php Pjax::begin(['id' => 'mainGridContainer']); ?> <?php echo TreeNavBarWidget::widget(['className' => NewsCategory::className(), 'parent_id' => $parent_id]); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['title', 'slug', ['label' => Yii::t('b/news/category', 'Status'), 'format' => 'raw', 'value' => function ($model, $index, $widget) { return Yii::t('b/news/category', 'status' . $model->status); }], ['label' => Yii::t('b/news/category', 'Subcategories'), 'format' => 'raw', 'value' => function ($model, $index, $widget) { return Html::a($model->getChildrenCount(), ['index', 'parent_id' => $model->id]); }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> <?php Pjax::end(); ?> </div> </div> </div>
/** * @return \yii\db\ActiveQuery */ public function getChildren() { return $this->hasMany(NewsCategory::className(), ['parent_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getParent() { return $this->hasOne(NewsCategory::className(), ['id' => 'parent_id']); }