[Form] fixed previous merge

This commit is contained in:
Fabien Potencier 2011-11-11 22:01:46 +01:00
parent 3922fb839a
commit 0427b126c1

View File

@ -142,8 +142,16 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer
));
}
if (!ctype_digit($value['month'].$value['day'].$value['year'])) {
throw new TransformationFailedException('This is an invalid date');
if (isset($value['month']) && !ctype_digit($value['month'])) {
throw new TransformationFailedException('This month an invalid');
}
if (isset($value['day']) && !ctype_digit($value['day'])) {
throw new TransformationFailedException('This day an invalid');
}
if (isset($value['year']) && !ctype_digit($value['year'])) {
throw new TransformationFailedException('This year an invalid');
}
if (!empty($value['month']) && !empty($value['day']) && !empty($value['year']) && false === checkdate($value['month'], $value['day'], $value['year'])) {