本文整理汇总了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.');
}
示例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);
}
示例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;
}