/** * @return string */ public function actionUp() { if (!User()->isGuest) { return $this->redirect(['/']); } $this->layout = '//wide'; $SignUpForm = \Yii::createObject(Account\frontend\forms\SignUpForm::className()); return $this->render('up', ['SignUpForm' => $SignUpForm]); }
/** * @return array */ public function actionUp() { $result = ['result' => false, 'message' => ['title' => \Yii::t('account', 'Sign Up'), 'text' => \Yii::t('account', 'Unknown error.')]]; /** @var Account\frontend\forms\SignUpForm $SignUpForm */ $SignUpForm = \Yii::createObject(Account\frontend\forms\SignUpForm::className()); if ($SignUpForm->load(Request()->post()) && $SignUpForm->validate() && $SignUpForm->register()) { $result = ['result' => true, 'message' => ['title' => \Yii::t('account', 'Sign Up'), 'text' => \Yii::t('account', 'Welcome!')], 'redirect' => UrlManager()->createUrl(['/'])]; } if ($SignUpForm->hasErrors()) { $result = ['result' => false, 'message' => ['title' => \Yii::t('account', 'Sign Up'), 'text' => \Yii::t('account', 'Form errors.')], 'errors' => $SignUpForm->getFirstErrors()]; } return $result; }