/**
  * Creates a new Nav model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Nav();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['nav/index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 2
0
 /**
  * Creates a new Nav model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Nav();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->parent == 0) {
             $model->saveNode();
         } else {
             if ($model->parent) {
                 $root = $this->findModel($model->parent);
                 $model->appendTo($root);
             }
         }
         return $this->render('tree');
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }