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


PHP AppModel::beforeValidate方法代码示例

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


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

示例1: beforeValidate

 public function beforeValidate($options = array())
 {
     parent::beforeValidate($options);
     $this->validate['Name']['notempty']['message'] = __d('contactform', 'please insert your name');
     $this->validate['Mail']['email']['message'] = __d('contactform', 'please insert your email address');
     $this->validate['Message']['notempty']['message'] = __d('contactform', 'please enter your message');
 }
开发者ID:pritten,项目名称:SmartCitizen.me,代码行数:7,代码来源:Contactform.php

示例2: beforeValidate

 public function beforeValidate()
 {
     parent::beforeValidate();
     if (isset($this->data[$this->alias]['url']) && !isset($this->data[$this->alias]['study_name'])) {
         $this->data[$this->alias]['study_name'] = $this->getTitle($this->data[$this->alias]['url']);
     }
     if (isset($this->data[$this->alias]['tag_list'])) {
         preg_match_all('/\\[([^\\]]*)\\]/', $this->data[$this->alias]['tag_list'], $matches);
         if (isset($matches[1])) {
             $this->data['Tag']['Tag'] = array();
             foreach ($matches[1] as $tag) {
                 $tagValue = mb_convert_kana($tag, 'as');
                 $conditions = array('LOWER(Tag.tag)' => strtolower($tagValue));
                 $this->Tag->contain();
                 $this->Tag->foreignKey();
                 $tag_id = $this->Tag->field('id', $conditions);
                 if (!$tag_id) {
                     $data = array('Tag' => array('tag' => $tagValue));
                     $this->Tag->create();
                     if (!$this->Tag->save($data)) {
                         return false;
                     }
                     $tag_id = $this->Tag->getInsertID();
                 }
                 $this->data['Tag']['Tag'][] = $tag_id;
             }
         }
         unset($this->data[$this->alias]['tag_list']);
     }
     return true;
 }
开发者ID:slywalker,项目名称:study_collect,代码行数:31,代码来源:study.php

示例3: beforeValidate

 /**
  * Handle beforeValidate callback
  *
  * @return void
  * @author hungnq
  **/
 public function beforeValidate($options = array())
 {
     if (isset($this->data[$this->name]['tel']) && is_array($this->data[$this->name]['tel'])) {
         $this->data[$this->name]['tel'] = implode('', array_filter($this->data[$this->name]['tel']));
     }
     return parent::beforeValidate($options);
 }
开发者ID:sonnt1991,项目名称:Goikenban,代码行数:13,代码来源:AdvisorProfile.php

示例4: beforeValidate

 function beforeValidate()
 {
     if (!parent::beforeValidate()) {
         return false;
     }
     $this->loadValidation();
 }
开发者ID:jamiemill,项目名称:missioncontrol_core,代码行数:7,代码来源:core_app_model.php

示例5: beforeValidate

 /**
  * beforeValidate callback
  *
  * @param array $options
  * @return boolean
  * @access public
  * @todo implement check of approved_from/approved_to
  */
 public function beforeValidate($options = array())
 {
     if (!parent::beforeValidate($options)) {
         return false;
     }
     return true;
 }
开发者ID:hadzi,项目名称:brekfarm,代码行数:15,代码来源:product.php

示例6: beforeValidate

 /**
  * CakePHP's beforeValidate callback.
  *
  * @return	boolean
  * @access	public
  */
 public function beforeValidate()
 {
     parent::beforeValidate();
     if (!empty($this->data)) {
         /**
          * An empty password value is never empty. The Auth module hashes
          * the empty value which makes it non-empty and fools the notEmpty
          * validation rule. This is bad.
          *
          * We want to recognize an empty password when we see one and
          * throw it out, so we have to make that adjustment manually.
          */
         $empty_password = Security::hash('', null, true);
         if (isset($this->data[$this->alias]['password']) && $this->data[$this->alias]['password'] === $empty_password) {
             if (!empty($this->id)) {
                 # When editing, just remove the data so no change is attempted.
                 unset($this->data[$this->alias]['password']);
                 unset($this->data[$this->alias]['confirm_password']);
             } else {
                 # When creating, empty the value so it will be caught by validation.
                 $this->data[$this->alias]['password'] = '';
                 $this->data[$this->alias]['confirm_password'] = '';
             }
         }
     }
     return true;
 }
开发者ID:robwilkerson,项目名称:CakePHP-Boilerplate,代码行数:33,代码来源:user.php

示例7: beforeValidate

 public function beforeValidate($options = array())
 {
     parent::beforeValidate();
     if ($this->data['User']['password'] == '') {
         unset($this->data['User']['password']);
     }
     return true;
 }
开发者ID:jet77,项目名称:DiabeteSavior,代码行数:8,代码来源:User.php

示例8: beforeValidate

 /**
  * Before Validation
  * @param array $options
  * @return boolean
  */
 public function beforeValidate($options = array())
 {
     // ignore empty file - causes issues with form validation when file is empty and optional
     if (!empty($this->data[$this->alias]['filename']['error']) && $this->data[$this->alias]['filename']['error'] == 4 && $this->data[$this->alias]['filename']['size'] == 0) {
         unset($this->data[$this->alias]['filename']);
     }
     parent::beforeValidate($options);
 }
开发者ID:Chwarles,项目名称:TRECH627TP3,代码行数:13,代码来源:Manufacturer.php

示例9: beforeValidate

 public function beforeValidate($options = array())
 {
     parent::beforeValidate($options);
     if (isset($this->data[$this->alias]['product_exchange_id'])) {
         $product = $this->ProductExchange->find('first', array('recursive' => -1, 'conditions' => array('ProductExchange.id' => $this->data[$this->alias]['product_exchange_id']), 'fields' => array('point_fee', 'money_fee', 'point_exchange', 'product_category_id', 'min_point_gift', 'min_point_money', 'exchange_gift_rate')));
         $this->data['ProductExchange'] = array('point_fee' => intval($product['ProductExchange']['point_fee']), 'money_fee' => intval($product['ProductExchange']['money_fee']), 'point_exchange' => $product['ProductExchange']['point_exchange'], 'product_category_id' => $product['ProductExchange']['product_category_id'], 'min_point_gift' => intval($product['ProductExchange']['min_point_gift']), 'min_point_money' => intval($product['ProductExchange']['min_point_money']), 'exchange_gift_rate' => $product['ProductExchange']['exchange_gift_rate']);
     }
 }
开发者ID:sonnt1991,项目名称:Goikenban,代码行数:8,代码来源:PointExchange.php

示例10: beforeValidate

 public function beforeValidate($options = array())
 {
     if (isset($this->data[$this->alias]['email'])) {
         // Always store email in lowercase
         $this->data[$this->alias]['email'] = strtolower($this->data[$this->alias]['email']);
     }
     return parent::beforeValidate($options);
 }
开发者ID:mathg,项目名称:skinsound,代码行数:8,代码来源:User.php

示例11: beforeValidate

 public function beforeValidate($options = array())
 {
     parent::beforeValidate();
     $date = date('Y-m-d H:i:s');
     if (empty($this->data['EventBlacklist']['id'])) {
         $this->data['EventBlacklist']['date_created'] = $date;
     }
     return true;
 }
开发者ID:jiekechoo,项目名称:MISP,代码行数:9,代码来源:EventBlacklist.php

示例12: beforeValidate

 public function beforeValidate($options = array())
 {
     $name = $this->data[$this->alias]['name'];
     switch ($name) {
         default:
             break;
     }
     return parent::beforeValidate($options);
 }
开发者ID:ivanbautsita,项目名称:gestion-escolar-campus-virtuales,代码行数:9,代码来源:ConfigItem.php

示例13: beforeValidate

 /**
  * Called during validation operations, before validation. Please note that custom
  * validation rules can be defined in $validate.
  *
  * @param array $options Options passed from Model::save().
  * @return bool True if validate operation should continue, false to abort
  * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate
  * @see Model::save()
  */
 public function beforeValidate($options = array())
 {
     $forgotPass = CakeSession::read('ForgotPass');
     if (!$forgotPass) {
         $forgotPass = array();
     }
     $this->validate = Hash::merge($this->validate, array('email' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Please input %s.', __d('auth', 'email')), 'required' => false), 'email' => array('rule' => array('email'), 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('auth', 'email'), __d('auth', 'email')))), 'authorization_key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Please input %s.', __d('auth', 'Authorization key')), 'required' => false), 'equalTo' => array('rule' => array('equalTo', Hash::get($forgotPass, 'authorization_key')), 'message' => __d('auth', 'Failed on validation errors. Please check the authorization key.'), 'required' => false))));
     return parent::beforeValidate($options);
 }
开发者ID:s-nakajima,项目名称:Auth,代码行数:18,代码来源:ForgotPass.php

示例14: beforeValidate

 /**
  * Called during validation operations, before validation. Please note that custom
  * validation rules can be defined in $validate.
  *
  * @param array $options Options passed from Model::save().
  *
  * @return boolean True if validate operation should continue, false to abort
  * @see Model::save()
  */
 public function beforeValidate($options = [])
 {
     parent::beforeValidate($options);
     if (Router::getParam('action') == 'admin_profile') {
         if ($this->data['User']['password'] == "" && $this->data['User']['confirm_password'] == "") {
             unset($this->data['User']['password']);
             unset($this->data['User']['confirm_password']);
         }
     }
 }
开发者ID:hurad,项目名称:hurad,代码行数:19,代码来源:User.php

示例15: beforeValidate

 /**
  * Antes de validar as informações
  * 
  * @return boolean
  */
 public function beforeValidate($options = array())
 {
     if (isset($this->data[$this->alias]['twitter'])) {
         $twitter = $this->data[$this->alias]['twitter'];
         $twitter = trim($twitter);
         $twitter = trim($twitter, '@');
         $this->data[$this->alias]['twitter'] = $twitter;
     }
     return parent::beforeValidate($options);
 }
开发者ID:ricardobylife,项目名称:Assando-Sites-2012,代码行数:15,代码来源:Information.php


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