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


PHP ActiveForm::validate方法代码示例

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


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

示例1: saveData

 public function saveData()
 {
     if ($this->model->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             // perform AJAX validation
             echo ActiveForm::validate($this->model);
             Yii::$app->end();
             return '';
         }
         /** @var User|bool $registeredUser */
         $registeredUser = $this->model->register();
         if ($registeredUser !== false) {
             $module = UsersModule::module();
             // login registered user if there's no need in confirmation
             $shouldLogin = $module->allowLoginInactiveAccounts || $module->emailConfirmationNeeded === false;
             if ($module->emailConfirmationNeeded === true && $registeredUser->is_active) {
                 $shouldLogin = true;
             }
             if ($shouldLogin && $registeredUser->login(UsersModule::module()->loginDuration)) {
                 $returnUrl = Yii::$app->request->get('returnUrl');
                 if ($returnUrl !== null) {
                     return $this->controller->redirect($returnUrl);
                 }
             }
             return $this->controller->goBack();
         }
     }
     return '';
 }
开发者ID:cheaterBY,项目名称:yii2-users-module,代码行数:30,代码来源:Registration.php

示例2: actionUser

 public function actionUser()
 {
     //make a db con or go back
     $db = new InstallConfig();
     try {
         $db->con();
     } catch (\yii\db\Exception $e) {
         return $this->render('config', array('model' => $db, "error" => "No DB"));
     }
     if (!User::find()->All() == null) {
         return $this->redirect('?r=install/finish');
         //Yii::$app->end();
     }
     //user
     $model = new User();
     $model->scenario = 'create';
     $model->language = 'he_il';
     $model->timezone = 'Asia/Jerusalem';
     if ($model->load(Yii::$app->request->post())) {
         //$model->save();
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return \yii\bootstrap\ActiveForm::validate($model);
         }
         if ($model->save()) {
             $this->redirect('?r=install/finish');
         }
     }
     return $this->render('user', array('model' => $model));
 }
开发者ID:chaimvaid,项目名称:linet3,代码行数:30,代码来源:InstallController.php

示例3: actionUser

 /**
  * регистрация юзера по имейл
  * если регистрация для покупки, то передаются параметры рекомендатель и урл
  * @param type $affiliate_id
  * @param type $url_id
  * @return type
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionUser($affiliate_id = null, $url_id = null)
 {
     $request = Yii::$app->request;
     $model = new \app\models\registration\UserForm();
     if ($request->isAjax && $model->load($request->post())) {
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load($request->post()) && $model->validate()) {
         $user = User::findByUsername($model->email);
         if (!$user) {
             $user = $model->save();
         }
         $user->setCookie();
         if ($affiliate_id === null || $url_id === null) {
             Yii::$app->session->setFlash('success', 'Регистрация успешна. Пароль выслан на почту');
             return $this->goHome();
         }
         $url = Url::findOne($url_id);
         if (!$url) {
             throw new \yii\web\NotFoundHttpException('Урл не найден');
         }
         $user->purchase($affiliate_id, $url);
         return $this->redirect($url->link);
     }
     return $this->render('user', ['model' => $model]);
 }
开发者ID:nicdnepr,项目名称:skidos,代码行数:35,代码来源:RegistrationController.php

示例4: actionValidateOptionsForm

 public function actionValidateOptionsForm()
 {
     $cOptFrm = new OptionsForm();
     if (Yii::$app->request->isAjax && $cOptFrm->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($cOptFrm);
     }
 }
开发者ID:Bibihelper,项目名称:Project2015,代码行数:8,代码来源:PrivateRoomController.php

示例5: run

 public function run()
 {
     $request = Yii::$app->getRequest();
     $this->modelComment = new BlogComment();
     if ($request->isAjax && $this->modelComment->load($request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         $errors = ActiveForm::validate($this->modelComment);
         echo json_encode($errors);
     }
 }
开发者ID:sircovsw,项目名称:yii2-sslab-blog,代码行数:10,代码来源:Validate.php

示例6: actionRegister

 public function actionRegister()
 {
     $model = new SignupForm();
     $model->scenario = 'short_register';
     if (\Yii::$app->request->isAjax && \Yii::$app->request->isPost) {
         \Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(\Yii::$app->request->post()) && $model->signup()) {
         print_r($model->getAttributes());
         die;
     }
     return $this->render("register", ['model' => $model]);
 }
开发者ID:sgsani,项目名称:yii.project,代码行数:14,代码来源:MainController.php

示例7: actionPassword_change

 public function actionPassword_change()
 {
     $model = new \app\models\Form\PasswordNew();
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->action(\Yii::$app->user->identity)) {
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->refresh();
     } else {
         return $this->render(['model' => $model]);
     }
 }
开发者ID:dram1008,项目名称:bogdan,代码行数:14,代码来源:Site_cabinetController.php

示例8: actionInfo

 public function actionInfo($id = '')
 {
     $model = new MenuForm();
     if (Yii::$app->request->isAjax && \Yii::$app->request->post('ajax', '') == 'info-form' && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post())) {
         $model->save();
         Yii::$app->end();
     }
     $model->update($id);
     return $this->render('info', ['model' => $model]);
 }
开发者ID:mademingshiwo,项目名称:todolist,代码行数:14,代码来源:MenuController.php

示例9: actionRegister

 public function actionRegister()
 {
     $model = new SignupForm();
     //$model->scenario = 'short_register';
     if (Yii::$app->request->isAjax && Yii::$app->request->isPost) {
         if ($model->load(Yii::$app->request->post())) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
     }
     if ($model->load(Yii::$app->request->post()) && $model->signup()) {
         Yii::$app->session->setFlash('success', 'Success register');
     }
     return $this->render('register', ['model' => $model]);
 }
开发者ID:karliv,项目名称:construction_company,代码行数:15,代码来源:MainController.php

示例10: actionLogin

 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     }
     return $this->render('login_form', ['model' => $model]);
 }
开发者ID:HaseProgram,项目名称:royalteams,代码行数:15,代码来源:SiteController.php

示例11: run

 public function run()
 {
     Yii::setAlias('@unclead-examples', realpath(__DIR__ . '/../'));
     $model = new ExampleModel();
     $request = Yii::$app->getRequest();
     if ($request->isPost && $request->post('ajax') !== null) {
         $model->load(Yii::$app->request->post());
         Yii::$app->response->format = Response::FORMAT_JSON;
         $result = ActiveForm::validate($model);
         return $result;
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
     }
     return $this->controller->render('@unclead-examples/views/example.php', ['model' => $model]);
 }
开发者ID:GAMITG,项目名称:yii2-multiple-input,代码行数:15,代码来源:MultipleInputAction.php

示例12: actionContact

 public function actionContact()
 {
     $this->layout = 'inner';
     $model = new ContactForm();
     if (Yii::$app->request->isAjax && $model->load(\Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $body = " <div>Body: <b> " . $model->body . " </b></div>";
         $body .= " <div>Email: <b> " . $model->email . " </b></div>";
         Yii::$app->common->sendMail($model->subject, $body);
         print 'Send success';
         die;
     }
     return $this->render('contact', ['model' => $model]);
 }
开发者ID:scorp7mix,项目名称:yii,代码行数:17,代码来源:MainController.php

示例13: actionConfigure

 public function actionConfigure()
 {
     $settings = PaypalSettings::find()->one();
     if ($settings->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($settings);
         }
         if ($settings->save()) {
             PaypalSubscriptionExpress::deleteAll();
             PaypalExpressPayment::deleteAll();
             Yii::$app->getSession()->setFlash('success', 'Paypal settings updated succesfully');
             return $this->refresh();
         }
     }
     return $this->render('configure', ['settings' => $settings]);
 }
开发者ID:achertovsky,项目名称:paypal-yii2,代码行数:17,代码来源:PaymentController.php

示例14: run

 /**
  * Registro de empresa
  * @return array|string|Response
  */
 public function run()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->controller->redirect('/');
     }
     $model = new EmpresaForm();
     $model->scenario = EmpresaForm::ESCENARIO_CREAR;
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($franquicia = $model->registrar()) {
             return $this->controller->render('registro-creado', ['model' => $franquicia]);
         }
     }
     return $this->controller->render('crear-cuenta', ['model' => $model]);
 }
开发者ID:alejandrososa,项目名称:AB,代码行数:22,代码来源:CrearAction.php

示例15: actionOrder

 public function actionOrder()
 {
     $model = new OrderForm();
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         $result = ActiveForm::validate($model);
         Yii::$app->response->format = Response::FORMAT_JSON;
         if (!empty($result)) {
             return $result;
         }
         if ($model->load(Yii::$app->request->post()) && $model->validate()) {
             if ($model->sendEmail(Setting::get('admin_email'))) {
                 return 'success';
             } else {
                 return 'error';
             }
         }
     }
 }
开发者ID:egor-pisarev,项目名称:altodis,代码行数:18,代码来源:SiteController.php


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