/** * Creates a new Category model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Category(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Category model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Category(); $parent = Categories::find()->all(); $media = Media::find()->orderBy('id DESC')->all(); $block = Block::find()->where(['type' => ''])->all(); $arr = CategoryTree::getTreeSelect(0); $arr1[0] = 'Нет'; foreach ($block as $v) { $arr1[$v->id] = $v->name; } /*$arr[0] = 'Нет'; foreach($parent as $v){ $arr[$v->id]=$v->name; }*/ if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model, 'parent' => $arr, 'media' => $media, 'block' => $arr1]); } }