當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CFormModel::beforeValidate方法代碼示例

本文整理匯總了PHP中CFormModel::beforeValidate方法的典型用法代碼示例。如果您正苦於以下問題:PHP CFormModel::beforeValidate方法的具體用法?PHP CFormModel::beforeValidate怎麽用?PHP CFormModel::beforeValidate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CFormModel的用法示例。


在下文中一共展示了CFormModel::beforeValidate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: beforeValidate

 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         $cams = array_map('trim', explode(',', $this->hcams));
         $c = count($cams);
         foreach ($cams as $cam) {
             $this->camBuff[] = Cams::model()->findByPK(Cams::model()->getRealId($cam));
         }
         $this->camBuff = array_filter($this->camBuff);
         if (empty($this->camBuff) || count($this->camBuff) != $c) {
             $this->addError('cams', $c > 1 ? Yii::t('errors', 'One of cam is wrong') : Yii::t('errors', 'There is no such cam'));
             return false;
         }
         if (!is_array($this->emails)) {
             $emails = array_map('trim', explode(',', $this->emails));
         } else {
             $emails = array_map('trim', $this->emails);
         }
         $c = count($emails);
         $this->emailBuff = Users::model()->findAllByAttributes(array('email' => $emails));
         if (empty($this->emailBuff) || count($this->emailBuff) != $c) {
             $this->addError('emails', $c > 1 ? Yii::t('errors', 'One of user is wrong') : Yii::t('errors', 'There is no such user'));
             return false;
         }
         return true;
     }
     return false;
 }
開發者ID:mrtos,項目名稱:OpenNVR,代碼行數:28,代碼來源:ShareForm.php

示例2: beforeValidate

 public function beforeValidate()
 {
     $this->db = Yii::app()->db;
     // Категория
     $category_id = $this->db->createCommand('
         SELECT id
         FROM yupe_store_category
         WHERE id_1c = ' . $this->category_id)->queryRow();
     if (empty($category_id)) {
         // категории нет в базе
         $this->category_id = '449';
     } else {
         // категория присутствует в базе, возвращаем ее идентификатор
         $this->category_id = $category_id['id'];
     }
     // Товар
     $product = $this->db->createCommand()->select('id, alias')->from('{{store_product}}')->where('id_1c=:id', [':id' => $this->id_1c])->queryRow();
     if (empty($product)) {
         // товар в базе не существует
         # code...
     } else {
         // товар существует
         $this->id = $product['id'];
         $this->alias = $product['alias'];
     }
     // Даты
     $this->create_time = date('Y-m-d h:m:s', time());
     $this->update_time = date('Y-m-d h:m:s', time());
     return parent::beforeValidate();
 }
開發者ID:QSODevelopers,項目名稱:yupe-storeswap,代碼行數:30,代碼來源:DProduct.php

示例3: beforeValidate

 protected function beforeValidate()
 {
     $this->message = strip_tags($this->message);
     $this->name = strip_tags($this->name);
     $this->telephone = strip_tags($this->telephone);
     return parent::beforeValidate();
 }
開發者ID:jankichaudhari,項目名稱:yii-site,代碼行數:7,代碼來源:PublicCareerForm.php

示例4: beforeValidate

 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         return true;
     }
     return false;
 }
開發者ID:jayrulez,項目名稱:kcconline,代碼行數:7,代碼來源:AddCategoryForm.php

示例5: beforeValidate

 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         $this->username = strtolower($this->username);
         return true;
     }
     return false;
 }
開發者ID:jayrulez,項目名稱:yiisns,代碼行數:8,代碼來源:LoginForm.php

示例6: beforeValidate

 public function beforeValidate()
 {
     if (empty($this->gender)) {
         $this->gender = self::GENDER_FEMALE;
     }
     $this->notime = !(isset($this->hour) && isset($this->minute) && $this->hour >= 0 && $this->hour <= 23 && $this->minute >= 0 && $this->minute <= 59);
     return parent::beforeValidate();
 }
開發者ID:kuzmina-mariya,項目名稱:happy-end,代碼行數:8,代碼來源:RegistrationForm.php

示例7: beforeValidate

 /**
  * Метод выполняется перед валидацией
  *
  * @return bool
  */
 public function beforeValidate()
 {
     $module = Yii::app()->getModule('user');
     if ($module->generateNickName) {
         $this->nick_name = 'user' . time();
     }
     return parent::beforeValidate();
 }
開發者ID:alextravin,項目名稱:yupe,代碼行數:13,代碼來源:RegistrationForm.php

示例8: beforeValidate

 protected function beforeValidate()
 {
     $this->show = (int) $this->show;
     foreach (array("show_user", "to", "tt") as $k) {
         $this->{$k} = trim($this->{$k});
     }
     $this->to_esc = preg_quote($this->to);
     $this->tt_esc = preg_quote($this->tt);
     return parent::beforeValidate();
 }
開發者ID:norayr,項目名稱:notabenoid,代碼行數:10,代碼來源:TrFilter.php

示例9: beforeValidate

 /**
 * Change our filename to match our own naming convention
 * @return bool
 */
 public function beforeValidate()
 {
     //(optional) Generate a random name for our file to work on preventing
     // malicious users from determining / deleting other users' files
     if ($this->secureFileNames) {
         $this->filename = sha1(Yii::app()->user->id . microtime() . $this->name);
         $this->filename .= "." . $this->file->getExtensionName();
     }
     return parent::beforeValidate();
 }
開發者ID:Rudianasaja,項目名稱:cycommerce,代碼行數:14,代碼來源:XUploadForm.php

示例10: beforeValidate

 /**
  * @return bool
  */
 public function beforeValidate()
 {
     /** @var AccountModule $account */
     $account = Yii::app()->getModule('account');
     if ($account->reCaptcha) {
         Yii::import('account.components.AccountReCaptchaValidator');
         $validator = new AccountReCaptchaValidator();
         $validator->attributes = array('captcha');
         $validator->validate($this);
         if ($this->hasErrors('captcha')) {
             return false;
         }
     }
     return parent::beforeValidate();
 }
開發者ID:cornernote,項目名稱:yii-account-module,代碼行數:18,代碼來源:AccountLostPassword.php

示例11: beforeValidate

 public function beforeValidate()
 {
     parent::beforeValidate();
     return true;
 }
開發者ID:ASDAFF,項目名稱:RosYama.2,代碼行數:5,代碼來源:GibddRuForm.php

示例12: beforeValidate

 public function beforeValidate()
 {
     parent::beforeValidate();
     $this->todayCount = $this->todaySended;
     if (Yii::app()->user->email) {
         $this->email = Yii::app()->user->email;
     }
     return true;
 }
開發者ID:ASDAFF,項目名稱:RosYama.2,代碼行數:9,代碼來源:DorogiMosForm.php

示例13: beforeValidate

 public function beforeValidate()
 {
     $this->validateSubForm();
     return parent::beforeValidate();
 }
開發者ID:rizabudi,項目名稱:plansys,代碼行數:5,代碼來源:Form.php

示例14: beforeValidate

 protected function beforeValidate()
 {
     $this->value = trim($this->value);
     $exists = false;
     foreach ($this->getVisibleSearchParameters() as $searchParam) {
         if ($searchParam->parameter->getIdParameter() == $this->parameter) {
             $exists = true;
             break;
         }
     }
     if (!$exists) {
         return false;
     }
     if ($objParameter = $this->getSearchObjectParamter()) {
         if ($objParameter->getType() == DataType::TIMESTAMP && !$this->parseTimestamp()) {
             return false;
         }
     }
     return parent::beforeValidate();
 }
開發者ID:kot-ezhva,項目名稱:ygin,代碼行數:20,代碼來源:ParameterSearchForm.php

示例15: beforeValidate

 /**
  * Loads the user model
  * @return boolean whether validation should continue
  */
 protected function beforeValidate()
 {
     $this->_user = User::model()->findCurrent();
     return parent::beforeValidate();
 }
開發者ID:pweisenburger,項目名稱:xbmc-video-server,代碼行數:9,代碼來源:ChangePasswordForm.php


注:本文中的CFormModel::beforeValidate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。