当前位置: 首页>>代码示例>>PHP>>正文


PHP SignupForm::getErrors方法代码示例

本文整理汇总了PHP中frontend\models\SignupForm::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP SignupForm::getErrors方法的具体用法?PHP SignupForm::getErrors怎么用?PHP SignupForm::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在frontend\models\SignupForm的用法示例。


在下文中一共展示了SignupForm::getErrors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testNotCorrectSignup

 public function testNotCorrectSignup()
 {
     $model = new SignupForm(['username' => 'troy.becker', 'email' => 'nicolas.dianna@hotmail.com', 'password' => 'some_password']);
     expect_not($model->signup());
     expect_that($model->getErrors('username'));
     expect_that($model->getErrors('email'));
     expect($model->getFirstError('username'))->equals('This username has already been taken.');
     expect($model->getFirstError('email'))->equals('This email address has already been taken.');
 }
开发者ID:yiisoft,项目名称:yii2-app-advanced,代码行数:9,代码来源:SignupFormTest.php

示例2: actionCreate

 public function actionCreate()
 {
     $model = new SignupForm();
     $parseData['model'] = $model;
     // get user types
     $types = $model->_types;
     $role = new Role();
     if ($role->isAdmin) {
         foreach ($types as $key => $value) {
             if ($value['value'] == User::TYPE_ADMIN) {
                 unset($types[$key]);
             }
         }
     }
     $parseData['types'] = $model->_prepareDataSelect($types, 'value', 'label');
     $post = Yii::$app->request->post();
     if ($post) {
         $model->load(Yii::$app->request->post());
         if ($model->validate()) {
             $model->signup();
             return $this->redirect(['index']);
         } else {
             $parseData['errors'] = $model->getErrors();
         }
     }
     return $this->render('create', $parseData);
 }
开发者ID:gpis88ce,项目名称:Gpis88ce,代码行数:27,代码来源:DefaultController.php

示例3: actionAjaxsignup

 public function actionAjaxsignup()
 {
     $res['status'] = 'error';
     $data = Yii::$app->request->post();
     $model = new SignupForm();
     if ($data) {
         $model->username = $data['email'];
         $model->email = $data['email'];
         $model->password = $data['password'];
         if ($user = $model->signup()) {
             $auth = Yii::$app->authManager;
             $role = $auth->getRole(User::ROLE_CUSTOMER);
             $auth->assign($role, $user->id);
             Yii::$app->getUser()->login($user);
             $res['status'] = 'ok';
         } else {
             $errors = $model->getErrors();
             $res['description_email'] = $errors['email'];
         }
     }
     echo json_encode($res);
     exit;
 }
开发者ID:ninetor,项目名称:yii-classifield,代码行数:23,代码来源:UserController.php


注:本文中的frontend\models\SignupForm::getErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。