public function __construct($config = array()) { parent::__construct($config); $categories = Category::find()->all(); foreach ($categories as $category) { $this->items[] = ['label' => $category->caption, 'url' => ['/product/category/' . $category->machine_name]]; } }
protected function getModel($id = null) { $model = null; if ($id) { $model = Category::findOne(["id" => $id]); } else { $model = new Category(); } return $model; }
<?php echo $form->field($model, 'cost'); ?> <?php echo $form->field($model, 'machine_name'); ?> <div class="form-group field-product-machine_name_Category required"> <label class="control-label" for="machine_name_Category"> <?php print Module::t("entity", $model->getAttributeLabel("machine_name_Category")); ?> </label> <div> <?php print Html::activeDropDownList($model, 'machine_name_Category', ArrayHelper::map(Category::find()->all(), 'machine_name', 'caption')); ?> </div> </div> <?php echo $form->field($model, 'description')->textArea(['rows' => '6']); ?> <?php echo $form->field($model, 'public')->checkbox(); ?> <div class="form-group"> <div class="col-lg-offset-1 col-lg-11"> <?php