controllers/AdminController.php
public function actionCreate($parent = 0)
    {
        $model = $this->module->model('Content');
        if (!isset($model->parent_id)) {
            $model->parent_id = $parent;
        }
        $post = Yii::$app->request->post();
        $loaded = $model->load($post);

        if ($loaded && $model->save()) {
            if ($model->aftersave != $model::AFTERSAVE_LIST) {
                return $this->redirect(['view', 'id' => $model->id]);
            } else {
                $model->orderBy = $model::$defaultOrderBy;
                $model->page = $model->calcPage($model::find()->where(['parent_id' => $model->parent_id]));
                return $this->redirect(['index',
                    'parent' => $model->parent_id,
                    'page'   => $model->page,
                    'id'     => $model->id,
                    'sort'   => $model->orderByToSort(),
                ]);
            }
        } else {
            return $this->render('create', compact('model'));
        }
    }
public function actionCreate($parent = 0)
    {
        $model = $this->module->model('Content');
        if (!isset($model->parent_id)) {
            $model->parent_id = $parent;
        }
        $post = Yii::$app->request->post();
        $loaded = $model->load($post);

        if ($loaded && $model->save()) {
            if ($model->aftersave != $model::AFTERSAVE_LIST) {
                return $this->redirect(['view', 'id' => $model->id]);
            } else {
                $model->orderBy = $model::$defaultOrderBy;
                $model->page = $model->calcPage($model::find()->where(['parent_id' => $model->parent_id]));
                return $this->redirect(['index',
                    'parent' => $model->parent_id,
                    'page'   => $model->page,
                    'id'     => $model->id,
                    'sort'   => $model->orderByToSort(),
                ]);
            }
        } else {
            return $this->render('create', compact('model'));
        }
    }
public function actionCreate ( $ parent = 0 ) { $ model = $ this -> module -> model ( 'Content' ) ; if ( ! isset ( $ model -> parent_id ) ) { $ model -> parent_id = $ parent ; } $ post = Yii :: $ app -> request -> post ( ) ; $ loaded = $ model -> load ( $ post ) ; if ( $ loaded && $ model -> save ( ) ) { if ( $ model -> aftersave != $ model :: AFTERSAVE_LIST ) { return $ this -> redirect ( [ 'view' , 'id' => $ model -> id ] ) ; } else { $ model -> orderBy = $ model :: $ defaultOrderBy ; $ model -> page = $ model -> calcPage ( $ model :: find ( ) -> where ( [ 'parent_id' => $ model -> parent_id ] ) ) ; return $ this -> redirect ( [ 'index' , 'parent' => $ model -> parent_id , 'page' => $ model -> page , 'id' => $ model -> id , 'sort' => $ model -> orderByToSort ( ) , ] ) ; } } else { return $ this -> render ( 'create' , compact ( 'model' ) ) ; } }
Creates a new Content model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Content model . If creation is successful the browser will be redirected to the view page .