/** * Create a menu * @return array|string|Response */ public function actionCreate() { $model = new Menu(); $this->layout = 'menu'; if ($model->load(Yii::$app->request->post())) { if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } else { if ($model->save()) { $this->flash('success', Yii::t('site', 'Menu created')); return $this->redirect(['/admin/' . $this->module->id]); } else { $this->flash('error', Yii::t('easyii', 'Create error. {0}', $model->formatErrors())); return $this->refresh(); } } } else { return $this->render('create', ['model' => $model]); } }