Пример #1
0
 public function actionSignup()
 {
     $model = new SignupForm();
     //ajax验证
     /*$model->load($_POST);
       if (Yii::$app->request->isAjax) {
           Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
           return \yii\bootstrap\ActiveForm::validate($model);
       }*/
     //表单提交
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             if ($model->sendEmail()) {
                 Yii::$app->session->setFlash('success', '你已经成功注册! :D      ');
             } else {
                 Yii::$app->session->setFlash('emailerror', '邮件发送失败   :(      ');
             }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }