Пример #1
0
 /**
  * Signs user up.
  *
  * @return mixed
  */
 public function actionSignup()
 {
     $model = new SignupForm();
     $this->layout = 'signup';
     if ($model->load(Yii::$app->request->post())) {
         //echo'<pre>';var_dump($model->birth_year);echo'</pre>';die;
         if ($model->birth_year == '' || $model->birth_month == '' || $model->birth_day == '') {
             Yii::$app->session->setFlash('error', Yii::t('app', 'SignupForm_fill_all_fields'));
         } elseif ($user = $model->signup()) {
             if ($model->sendEmail($model->email)) {
                 //Yii::$app->session->setFlash('success', Yii::t('app', 'SignupForm_reg_success'));
             } else {
                 Yii::$app->session->setFlash('error', Yii::t('app', 'Error_sending_email'));
             }
             return $this->redirect(['index', 'reg-success' => 1]);
             //                if (Yii::$app->getUser()->login($user)) {
             //                    return $this->goHome();
             //                }
         } else {
             Yii::$app->session->setFlash('error', Yii::t('app', 'SignupForm_error_form'));
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #2
0
 public function actionSignup()
 {
     $model = new SignupForm();
     Yii::$app->response->format = 'json';
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail(Yii::$app->params['contactEmail'])) {
             return ['message' => Yii::t('app', 'Thank you for your interest. We will respond to you as soon as possible.'), 'status' => 'success'];
         } else {
             return ['message' => Yii::t('app', 'There was an error during request.'), 'status' => 'error'];
         }
     } else {
         return ['message' => Yii::t('app', 'There was an error during processing your inputs.'), 'status' => 'error'];
     }
 }