當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。