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


PHP CActiveRecordBehavior::beforeValidate方法代码示例

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


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

示例1: beforeValidate

 /**
  * Actions to take before validating the owner.
  * @param CModelEvent $event
  */
 public function beforeValidate($event)
 {
     parent::beforeValidate($event);
     if ($this->owner->hasAttribute($this->statusAttribute) && !isset($this->owner->{$this->statusAttribute})) {
         $this->owner->{$this->statusAttribute} = $this->defaultStatus;
     }
 }
开发者ID:crisu83,项目名称:yii-workflow,代码行数:11,代码来源:WorkflowBehavior.php

示例2: beforeValidate

 /**
  * @param CModelEvent $event
  */
 public function beforeValidate($event)
 {
     if (method_exists($this->getOwner(), 'setDefaultAttributes')) {
         $this->getOwner()->setDefaultAttributes();
     }
     // will the following will be called twice?
     return parent::beforeValidate($event);
 }
开发者ID:cornernote,项目名称:yii-dressing,代码行数:11,代码来源:YdDefaultAttributesBehavior.php

示例3: beforeValidate

 public function beforeValidate($event)
 {
     parent::beforeValidate($event);
     foreach ($this->fields as $field) {
         if (!is_a($this->owner->{$field}, 'CUploadedFile')) {
             $this->owner->{$field} = CUploadedFile::getInstance($this->owner->model(), $field);
         }
     }
     return true;
 }
开发者ID:nurirahmat,项目名称:Yii-Extensions,代码行数:10,代码来源:HasImage.php

示例4: beforeValidate

 public function beforeValidate($event)
 {
     $owner = $this->getOwner();
     //salt
     if ($owner->getIsNewRecord() && $owner->hasAttribute('salt')) {
         $owner->salt = Common::generateSalt();
     }
     if ($owner->getScenario() === Users::SCENARIO_CHANGE_PASSWORD) {
         $owner->currentPassword = $owner->salt . md5($owner->currentPassword);
     }
     return parent::beforeValidate($event);
 }
开发者ID:wanyos2005,项目名称:hsbf,代码行数:12,代码来源:UserBehavior.php

示例5: beforeValidate

 public function beforeValidate($event)
 {
     if (isset(Yii::app()->user)) {
         $availableColumns = array_keys($this->owner->tableSchema->columns);
         if ($this->owner->isNewRecord && empty($this->owner->{$this->createdByColumn})) {
             if (in_array($this->createdByColumn, $availableColumns)) {
                 $this->owner->{$this->createdByColumn} = Yii::app()->user->id;
             }
         }
         if (empty($this->owner->{$this->updatedByColumn})) {
             if (in_array($this->updatedByColumn, $availableColumns)) {
                 $this->owner->{$this->updatedByColumn} = Yii::app()->user->id;
             }
         }
     }
     return parent::beforeValidate($event);
 }
开发者ID:Edilber,项目名称:ManagerPathFinderSystem,代码行数:17,代码来源:BlameableBehavior.php

示例6: beforeValidate

 public function beforeValidate($event)
 {
     $setAttributes = array();
     foreach ($this->attributes as $attribute => $format) {
         if (!$this->owner->hasAttribute($attribute)) {
             continue;
         }
         $value = $this->owner->getAttribute($attribute);
         if (empty($value) && $this->autoFill === false) {
             continue;
         }
         if (empty($value)) {
             $value = time();
         } else {
             if (!is_numeric($value)) {
                 $value = strtotime($value);
             }
         }
         $setAttributes[$attribute] = $value;
     }
     $this->owner->setAttributes($setAttributes);
     return parent::beforeValidate($event);
 }
开发者ID:GsHatRed,项目名称:Yiitest,代码行数:23,代码来源:DateFormatBehavior.php

示例7: beforeDelete

 public function beforeDelete($event)
 {
     UserFollow::model()->deleteAllByAttributes(array('object_model' => get_class($this->getOwner()), 'object_id' => $this->getOwner()->getPrimaryKey()));
     return parent::beforeValidate($event);
 }
开发者ID:alefernie,项目名称:intranet,代码行数:5,代码来源:HFollowableBehavior.php

示例8: beforeValidate

 /**
  * Invoked before the model is validated.
  * Validates the password first
  * @param CModelEvent $event the raised event
  */
 public function beforeValidate($event)
 {
     $password = $event->sender->{$this->passwordAttribute};
     $strategy = $this->getStrategy();
     if ($strategy !== false && $password != $this->_hashedPassword && $password != "") {
         $strategy->attributes = array($this->passwordAttribute);
         $strategy->validate($event->sender);
     }
     return parent::beforeValidate($event);
 }
开发者ID:LumbaJack,项目名称:Mercado-BTX,代码行数:15,代码来源:APasswordBehavior.php

示例9: beforeValidate

 /**
  * @param CModelEvent $event
  */
 public function beforeValidate($event)
 {
     $this->getOwner()->setDefaultAttributes();
     return parent::beforeValidate($event);
 }
开发者ID:zainengineer,项目名称:yii-dressing,代码行数:8,代码来源:YdDefaultAttributesBehavior.php


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