From b9f9b165361b12465d10bc874ef39ec37701b921 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 6 Dec 2013 10:58:54 -0500 Subject: [PATCH] Apply fix for #1003 to validateAttribute. --- framework/yii/validators/DateValidator.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/yii/validators/DateValidator.php b/framework/yii/validators/DateValidator.php index 5354b71..60210bd 100644 --- a/framework/yii/validators/DateValidator.php +++ b/framework/yii/validators/DateValidator.php @@ -56,7 +56,8 @@ class DateValidator extends Validator return; } $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); } elseif ($this->timestampAttribute !== null) { $object->{$this->timestampAttribute} = $date->getTimestamp();