/** * 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->validate()) { if (!isset($model->parentId)) { $result = $model->saveNode(); } else { $parent = Category::findOne($model->parentId); $result = $model->appendTo($parent); } if ($result) { return $this->redirect(['view', 'id' => $model->id]); } } return $this->render('create', ['model' => $model]); }