本文整理汇总了PHP中frontend\models\SignupForm::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP SignupForm::validate方法的具体用法?PHP SignupForm::validate怎么用?PHP SignupForm::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类frontend\models\SignupForm
的用法示例。
在下文中一共展示了SignupForm::validate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: actionSignUp
public function actionSignUp()
{
$model = new SignupForm();
if ($model->load(Yii::$app->getRequest()->getBodyParams(), '') && $model->validate()) {
$user = $model->signup();
if ($user) {
Yii::$app->user->login($user, 3600 * 24 * 30);
$response = ['access_token' => Yii::$app->user->identity->getAuthKey(), 'flash' => ['class' => 'success', 'message' => 'Thank you. You are successfully sign up.']];
} else {
$response = ['flash' => ['class' => 'error', 'message' => 'Something wrong.']];
}
return $response;
} else {
$model->validate();
return $model;
}
}
示例3: actionRegister
public function actionRegister()
{
$registerForm = new SignupForm();
if ($registerForm->load(\Yii::$app->request->post()) && $registerForm->validate()) {
/*
\Yii::$app->common->sendMail(Html::encode($registerForm->email), Html::encode($registerForm->username), Html::encode($registerForm->password_hash));
$userModel = new UserDbModel();
$userModel->username = Html::encode($registerForm->username);
$userModel->email = Html::encode($registerForm->email);
$userModel->password_hash = \Yii::$app->security->generatePasswordHash(Html::encode($registerForm->password_hash));
$userModel->generateAuthKey();
$userModel->save();
//*/
$registerForm->signup();
return $this->render('registerView', ['formModel' => $registerForm, 'success' => true]);
} else {
return $this->render('registerView', ['formModel' => $registerForm]);
}
}
示例4: actionSignup
/**
* The signup page
* @return string|\yii\web\Response
*/
public function actionSignup()
{
//$this->layout = 'main';
$this->layout = 'login';
$model = new SignupForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($this->createUser(['name' => $model->name, 'email' => $model->email])) {
Yii::$app->session->setFlash('success', Yii::t('app', 'Your account as been created successfully. Please check your email for login instructions.'));
return $this->redirect(Yii::$app->user->loginUrl);
} else {
Yii::$app->session->setFlash('error', Yii::t('app', 'Sorry, something went wrong. We\'re working on getting this fixed as soon as we can.'));
}
}
return $this->render('signup', ['model' => $model]);
}
示例5: actionRegisterStore
public function actionRegisterStore()
{
$this->layout = 't2/main';
$userModel = new SignupForm();
$storeModel = new Store();
$user_id = 0;
if ($userModel->load(Yii::$app->request->post()) && $storeModel->load(Yii::$app->request->post())) {
// print_r($storeModel->validate()); exit;
if (Yii::$app->user->isGuest) {
if ($userModel->validate() && ($user = $userModel->signup())) {
$user_id = $user->id;
} else {
return $this->render('registerStore', ['userModel' => $userModel, 'storeModel' => $storeModel]);
}
} else {
$user_id = \Yii::$app->user->identity->id;
}
$store_img = UploadedFile::getInstances($storeModel, 'file');
if ($storeModel->validate()) {
if (!empty($store_img)) {
$storeModel->file = $store_img[0];
$image_name = '/store/' . $storeModel->file->baseName . '_' . time() . '.' . $storeModel->file->extension;
$image_path = Yii::getAlias('@frontend') . '/web/uploads' . $image_name;
$storeModel->file->saveAs($image_path);
$storeModel->store_picture = $image_name;
}
if ($storeModel->save()) {
$store_id = $storeModel->store_id;
$userStore = new UserStore();
$userStore->user_id = $user_id;
$userStore->store_id = $store_id;
$userStore->save();
return $this->redirect(Yii::$app->urlManager->getBaseUrl() . '/backend/web/');
} else {
print_r($storeModel->error);
exit;
}
// }
} else {
print_r($storeModel->errors);
exit;
return $this->render('registerStore', ['userModel' => $userModel, 'storeModel' => $storeModel]);
}
echo '<pre>';
print_r($storeModel);
print_r($store_img);
exit;
}
// $store_img = UploadedFile::getInstances($storeModel, 'file');
// $storeModel->file = $store_img[0];
// if($storeModel->validate()) {
// if(!empty($store_img)){
// $image_name = '/store/' . $storeModel->file->baseName . '_' . time() . '.' . $storeModel->file->extension;
// $image_path = Yii::getAlias('@frontend'). '/web/uploads' . $image_name;
// $storeModel->file->saveAs( $image_path);
// $storeModel->store_picture = $image_name;
// if($storeModel->save()) {
// $store_id = $storeModel->store_id;
// $user_id = \Yii::$app->user->identity->id;
// echo $store_id;
// echo $user_id;
// exit;
// }
// }
// // return $this->redirect(['view', 'id' => $model->store_id]);
// } else {
// // return $this->render('update', [
// // 'model' => $model,
// // ]);
// }
return $this->render('registerStore', ['userModel' => $userModel, 'storeModel' => $storeModel]);
}
示例6: actionSubmitSignup
public function actionSubmitSignup()
{
$model = new SignupForm();
$model->setScenario('user-create');
$submitResponse[] = '';
if ($model->load(Yii::$app->request->post())) {
Yii::$app->response->format = 'json';
if ($model->validate() && $model->signup()) {
$model->sendEmailActivation();
$submitResponse = ['isSuccess' => true, 'message' => 'Registrasi Berhasil, Silahkan aktifkan akun anda melalui email.'];
return $submitResponse;
} else {
$submitResponse = ['isSuccess' => false, 'message' => 'Registrasi Gagal'];
echo $submitResponse;
}
}
}
示例7: actionSignup
public function actionSignup()
{
$model = new SignupForm();
Yii::$app->response->format = 'json';
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail(Yii::$app->params['contactEmail'])) {
return ['message' => Yii::t('app', 'Thank you for your interest. We will respond to you as soon as possible.'), 'status' => 'success'];
} else {
return ['message' => Yii::t('app', 'There was an error during request.'), 'status' => 'error'];
}
} else {
return ['message' => Yii::t('app', 'There was an error during processing your inputs.'), 'status' => 'error'];
}
}
示例8: actionExist
public function actionExist()
{
$params = Yii::$app->getRequest()->getBodyParams();
$user = User::findByUsername($params);
if (!$user) {
$model = new SignupForm();
$isLoad = $model->load($params, '');
$user = $model->signup();
if ($isLoad && $user) {
Yii::$app->user->login($user);
return ['access_token' => $user->getAuthKey(), 'user_id' => $user->getId()];
} else {
$model->validate();
return $model;
}
} else {
Yii::$app->user->login($user);
return ['access_token' => $user->getAuthKey(), 'user_id' => $user->getId()];
}
return null;
}
示例9: actionSignup
/**
* Signs user up.
*
* @return mixed
*/
public function actionSignup()
{
$model = new SignupForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($user = $model->signup()) {
//if (Yii::$app->getUser()->login($user)) {
return $this->goHome();
//}
}
} else {
return $this->render('signup', ['model' => $model]);
}
}