public function actionIndex() { $model = new EmailConsoleForm(); if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) { $model->load(\Yii::$app->request->post()); \Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } $result = ""; if ($model->load(\Yii::$app->request->post()) && $model->execute()) { $result = \Yii::t('app', "Submitted"); } else { if (\Yii::$app->request->post()) { $result = \Yii::t('app', "Not sent"); } } return $this->render('index', ['model' => $model, 'result' => $result]); }
/** * Updates an existing Game model. * If update is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionChangePassword() { $model = $this->model; $modelForm = new PasswordChangeForm(['user' => $model]); if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) { $modelForm->load(\Yii::$app->request->post()); \Yii::$app->response->format = Response::FORMAT_JSON; return \skeeks\cms\modules\admin\widgets\ActiveForm::validate($modelForm); } if ($modelForm->load(\Yii::$app->request->post()) && $modelForm->changePassword()) { \Yii::$app->getSession()->setFlash('success', 'Успешно сохранено'); return $this->redirect(['change-password', 'id' => $model->id]); } else { if (\Yii::$app->request->isPost) { \Yii::$app->getSession()->setFlash('error', 'Не удалось изменить пароль'); } return $this->output(\Yii::$app->cms->moduleCms()->renderFile('admin-user/change-password.php', ['model' => $modelForm])); /*return $this->render('_form-change-password', [ 'model' => $modelForm, ]);*/ } }