mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-22 19:31:02 +08:00
Apply fix for #1003 to validateAttribute.
This commit is contained in:
@ -56,7 +56,8 @@ class DateValidator extends Validator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$date = DateTime::createFromFormat($this->format, $value);
|
$date = DateTime::createFromFormat($this->format, $value);
|
||||||
if ($date === false) {
|
$errors = DateTime::getLastErrors();
|
||||||
|
if ($date === false || $errors['error_count'] || $errors['warning_count']) {
|
||||||
$this->addError($object, $attribute, $this->message);
|
$this->addError($object, $attribute, $this->message);
|
||||||
} elseif ($this->timestampAttribute !== null) {
|
} elseif ($this->timestampAttribute !== null) {
|
||||||
$object->{$this->timestampAttribute} = $date->getTimestamp();
|
$object->{$this->timestampAttribute} = $date->getTimestamp();
|
||||||
|
Reference in New Issue
Block a user