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