本文整理汇总了PHP中YumUser::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP YumUser::getErrors方法的具体用法?PHP YumUser::getErrors怎么用?PHP YumUser::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YumUser
的用法示例。
在下文中一共展示了YumUser::getErrors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
public function actionCreate()
{
// if some data has been entered before or the user is already logged in,
// take the already existing data and prefill the input form
if ($model = Shop::getCustomer()) {
$address = $model->address;
} else {
$model = new Customer();
}
if (isset($_POST['Customer'])) {
$model->attributes = $_POST['Customer'];
if (isset($_POST['Address'])) {
$address = new Address();
$address->attributes = $_POST['Address'];
if ($address->save()) {
$model->address_id = $address->id;
}
}
if (!Yii::app()->user->isGuest) {
$model->user_id = Yii::app()->user->id;
}
$model->validate();
if (Shop::module()->useWithYum && isset($_POST['register']) && ($_POST['register'] = true)) {
if (isset($_POST['Customer']['password']) && isset($_POST['Customer']['passwordRepeat'])) {
if ($_POST['Customer']['password'] != $_POST['Customer']['passwordRepeat']) {
$model->addError('password', Shop::t('Passwords do not match'));
} else {
if ($_POST['Customer']['password'] == '') {
$model->addError('password', Shop::t('Password is empty'));
} else {
$user = new YumUser();
$profile = new YumProfile();
$profile->attributes = $_POST['Customer'];
$profile->attributes = $_POST['Address'];
if ($user->register(strtr($model->email, array('@' => '_', '.' => '_')), $_POST['Customer']['password'], $profile)) {
$user->status = YumUser::STATUS_ACTIVE;
$user->save(false, array('status'));
$model->user_id = $user->id;
Shop::setFlash(Shop::t('Successfully registered user'));
} else {
$model->addErrors($user->getErrors());
$model->addErrors($profile->getErrors());
Shop::setFlash(Shop::t('Error while registering user'));
}
}
}
}
}
if (!$model->hasErrors()) {
if ($model->save()) {
Yii::app()->user->setState('customer_id', $model->customer_id);
$this->redirect(array('//shop/order/create', 'customer' => $model->customer_id));
}
}
}
$this->render('create', array('customer' => $model, 'address' => isset($address) ? $address : new Address()));
}