本文整理汇总了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;
}
示例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();
}
示例3: beforeValidate
public function beforeValidate()
{
if (strlen($this->ip) > 0 && $this->address == '') {
$this->address = gethostbyaddr($this->ip);
}
return parent::beforeValidate();
}
示例4: beforeValidate
public function beforeValidate()
{
if (is_array($this->links)) {
$this->links = implode(",", $this->links);
}
return parent::beforeValidate();
}
示例5: beforeValidate
/**
* Adding unique key generation
* @inheritdoc
*/
public function beforeValidate()
{
if (empty($this->key)) {
$this->key = uniqid('template-region-', true);
}
return parent::beforeValidate();
}
示例6: beforeValidate
/**
* @inheritdoc
*/
public function beforeValidate()
{
if ($this->isNewRecord) {
$this->authKey = Module::getInstance()->getTokenGenerator()->generate();
}
return parent::beforeValidate();
}
示例7: beforeValidate
public function beforeValidate()
{
if (empty($this->created)) {
$this->created = date('Y-m-d H:i:s');
}
return parent::beforeValidate();
}
示例8: beforeValidate
public function beforeValidate()
{
if ($this->parent_id == null) {
$this->parent_id = 0;
}
return parent::beforeValidate();
}
示例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();
}
示例10: beforeValidate
public function beforeValidate()
{
if ($this->isNewRecord) {
$this->created_at = time();
}
return parent::beforeValidate();
}
示例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();
}
示例12: beforeValidate
public function beforeValidate()
{
if ($this->isNewRecord && $this->scenario != 'default') {
$this->created_at = time();
}
return parent::beforeValidate();
}
示例13: beforeValidate
/**
* @inheritdoc
*/
public function beforeValidate()
{
if (!empty($this->dateString)) {
$this->date = strtotime($this->dateString . ' 00:00:01');
}
return parent::beforeValidate();
}
示例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();
}
示例15: beforeValidate
public function beforeValidate()
{
if (isset(Yii::$app->controller->module->sectionId)) {
$this->section_id = Yii::$app->controller->module->sectionId;
}
return parent::beforeValidate();
}