public function actionCreate()
    {
        $this->layout = static::FORM_LAYOUT;
        $model = new $this->MainModel;

        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            if(empty($model->Menu_id)) {
                Yii::info('Making the new node as root');
                $model->makeRoot();
            } else {
                $parent_node = Menu::findOne($model->Menu_id);
                $model->appendTo($parent_node);

                Yii::info('Making the new node as a child of ' . $parent_node->id);
            }
            $this->saveHistory($model, $this->historyField);
            return $this->redirect(['index']);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }
public function actionCreate()
    {
        $this->layout = static::FORM_LAYOUT;
        $model = new $this->MainModel;

        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            if(empty($model->Menu_id)) {
                Yii::info('Making the new node as root');
                $model->makeRoot();
            } else {
                $parent_node = Menu::findOne($model->Menu_id);
                $model->appendTo($parent_node);

                Yii::info('Making the new node as a child of ' . $parent_node->id);
            }
            $this->saveHistory($model, $this->historyField);
            return $this->redirect(['index']);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }
public function actionCreate ( ) { $ this -> layout = static :: FORM_LAYOUT ; $ model = new $ this -> MainModel ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> validate ( ) ) { if ( empty ( $ model -> Menu_id ) ) { Yii :: info ( 'Making the new node as root' ) ; $ model -> makeRoot ( ) ; } else { $ parent_node = Menu :: findOne ( $ model -> Menu_id ) ; $ model -> appendTo ( $ parent_node ) ; Yii :: info ( 'Making the new node as a child of ' . $ parent_node -> id ) ; } $ this -> saveHistory ( $ model , $ this -> historyField ) ; return $ this -> redirect ( [ 'index' ] ) ; } else { return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; } }
Creates a new Faq model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Faq model . If creation is successful the browser will be redirected to the view page .