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


PHP ActiveRecord::beforeValidate方法代码示例

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


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

示例1: beforeValidate

 /**
  * vendor/yiisoft/yii2/base/Model.php
  */
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         //convert to (MYSQL) storage format
         /**
         			 * http://www.yiiframework.com/wiki/684/save-and-display-date-time-fields-in-different-formats-in-yii2/ 
         			 * = verder uitwerken uitzoeken of mogelijk om automatisch alle number, date, timestamps te convertren...???
         			 * o.a fout in bower/jquery-ui/ui/i18n/datepicker-nl.js
         			 * //monthNamesShort: ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
         			 * monthNamesShort: ['jan.', 'feb.', 'mrt.', 'apr.', 'mei', 'jun.', 'jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'],
         			 * Denk na aanpassing eraan om assets op te schonen...
         https://github.com/yiisoft/yii2/pull/3906
         			 what happened to unformat/prser... ???
         */
         //$saveFormat = 'Y-m-d';
         //$dispDate = $this->date1;
         //$this->date1 = DateTime::createFromFormat($dispFormat, $dispDate);
         //$this->date1 = date($saveFormat, Yii::$app->formatter->asTimestamp($dispDate));
         //DateTime::createFromFormat('Y-m-d', $value);
         //Let op! een fout hier geeft 'no results found' bij ALLE index pagina's 2014-12-13
         //$this->date1 = \Yii::$app->formatter->asDate($this->date1, 'php:Y-m-d');//2014-12-11 werkt wel voor Engelse jan, feb, maar niet voor Nederlandse
         //$this->info1 = '123';//new \yii\db\Expression('NOW()');
         return true;
     }
     return false;
 }
开发者ID:csa12,项目名称:yii2,代码行数:29,代码来源:ActiveRecord.php

示例2: beforeValidate

 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if (is_callable($this->beforeValidate)) {
         return parent::beforeValidate() && call_user_func_array($this->beforeValidate, [$this, 'beforeValidate']);
     }
     return parent::beforeValidate();
 }
开发者ID:kfosoft,项目名称:yii2-app-dynamic-options,代码行数:10,代码来源:Option.php

示例3: beforeValidate

 public function beforeValidate()
 {
     if (strlen($this->ip) > 0 && $this->address == '') {
         $this->address = gethostbyaddr($this->ip);
     }
     return parent::beforeValidate();
 }
开发者ID:dextercool,项目名称:yii2-yiiboard,代码行数:7,代码来源:YBoardIpaddress.php

示例4: beforeValidate

 public function beforeValidate()
 {
     if (is_array($this->links)) {
         $this->links = implode(",", $this->links);
     }
     return parent::beforeValidate();
 }
开发者ID:oakcms,项目名称:oakcms,代码行数:7,代码来源:Text.php

示例5: beforeValidate

 /**
  * Adding unique key generation
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if (empty($this->key)) {
         $this->key = uniqid('template-region-', true);
     }
     return parent::beforeValidate();
 }
开发者ID:DevGroup-ru,项目名称:dotplant-monster,代码行数:11,代码来源:TemplateRegion.php

示例6: beforeValidate

 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->authKey = Module::getInstance()->getTokenGenerator()->generate();
     }
     return parent::beforeValidate();
 }
开发者ID:nordsoftware,项目名称:yii2-account,代码行数:10,代码来源:Account.php

示例7: beforeValidate

 public function beforeValidate()
 {
     if (empty($this->created)) {
         $this->created = date('Y-m-d H:i:s');
     }
     return parent::beforeValidate();
 }
开发者ID:rcjusto,项目名称:simplestore,代码行数:7,代码来源:UserAuthorizeNet.php

示例8: beforeValidate

 public function beforeValidate()
 {
     if ($this->parent_id == null) {
         $this->parent_id = 0;
     }
     return parent::beforeValidate();
 }
开发者ID:range-web,项目名称:yii2-rw-comments,代码行数:7,代码来源:Comments.php

示例9: beforeValidate

 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     $this->total_price = PriceHelper::getProductPrice($this->product, $this->order, $this->quantity);
     $this->discount_amount = $this->quantity * $this->price_per_pcs - $this->total_price;
     $this->total_price_without_discount = $this->total_price + $this->discount_amount;
     return parent::beforeValidate();
 }
开发者ID:ar7n,项目名称:dotplant2,代码行数:10,代码来源:OrderItem.php

示例10: beforeValidate

 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->created_at = time();
     }
     return parent::beforeValidate();
 }
开发者ID:cnzhangxl,项目名称:lnsoft,代码行数:7,代码来源:ActVoteLog.php

示例11: beforeValidate

 public function beforeValidate()
 {
     if ($this->type_key == self::TYPE_FILE && ($file = UploadedFile::getInstance(new SettingForm(), $this->key))) {
         $this->_value = $file;
     }
     return parent::beforeValidate();
 }
开发者ID:platx,项目名称:yii2-settings,代码行数:7,代码来源:Setting.php

示例12: beforeValidate

 public function beforeValidate()
 {
     if ($this->isNewRecord && $this->scenario != 'default') {
         $this->created_at = time();
     }
     return parent::beforeValidate();
 }
开发者ID:cnzhangxl,项目名称:lnsoft,代码行数:7,代码来源:Piece.php

示例13: beforeValidate

 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if (!empty($this->dateString)) {
         $this->date = strtotime($this->dateString . ' 00:00:01');
     }
     return parent::beforeValidate();
 }
开发者ID:DarkAngel36,项目名称:testtask,代码行数:10,代码来源:Books.php

示例14: beforeValidate

 /**
  * @return \yii\db\ActiveQuery
  */
 public function beforeValidate()
 {
     isset($this->str_id) ?: ($this->str_id = Yii::$app->request->get('id'));
     $this->uid = Yii::$app->user->identity->id;
     // $this->setAttributes(['uid'=>Yii::$app->user->identity->id]);
     return parent::beforeValidate();
 }
开发者ID:infun3,项目名称:translator,代码行数:10,代码来源:Comments.php

示例15: beforeValidate

 public function beforeValidate()
 {
     if (isset(Yii::$app->controller->module->sectionId)) {
         $this->section_id = Yii::$app->controller->module->sectionId;
     }
     return parent::beforeValidate();
 }
开发者ID:ut8ia,项目名称:yii2-content-module,代码行数:7,代码来源:ContentRubrics.php


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