/** * Edit menu * @param $id * @return array|string|Response */ public function actionEdit($id) { $model = MenuItem::findOne($id); if ($model === null) { $this->flash('error', Yii::t('easyii', 'Not found')); return $this->redirect(['/admin/' . $this->module->id]); } 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 item updated')); } else { $this->flash('error', Yii::t('site', 'Update error. {0}', $model->formatErrors())); } return $this->refresh(); } } else { return $this->render('edit', ['model' => $model]); } }