public function actionCreate() { $model = new MWxMenu(); $gh = Yii::$app->user->gh; $model->gh_id = $gh->gh_id; if ($model->load(Yii::$app->request->post())) { if ($model->is_sub_button) { $model->type = ''; $model->parent_id = 0; $model->url = ''; } if ($model->save()) { return $this->redirect(['index']); } } else { $model->sort_order = MWxMenu::getNextSortOrder($model->gh_id); return $this->render('create', ['model' => $model, 'gh' => $gh]); } }