Added check for array fields to be integers in reverseTransform method. This prevents checkdate from getting strings as arguments and throwing incorrect ErrorException when submitting form with malformed (string) data in, for example, Date field. #2609

This commit is contained in:
ondrowan 2011-11-11 09:58:40 +01:00
parent f8164ec380
commit 8351a11286

View File

@ -142,6 +142,10 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer
));
}
if (preg_match( '/^\d*$/', $value['month'] . $value['day'] . $value['year']) === 0) {
throw new TransformationFailedException('This is an invalid date');
}
if (!empty($value['month']) && !empty($value['day']) && !empty($value['year']) && false === checkdate($value['month'], $value['day'], $value['year'])) {
throw new TransformationFailedException('This is an invalid date');
}