Description
In Symfony-2.6.7, I am using a form with type date
, 'format' => 'yyyy-MM-dd'
and constraint => array(new Symfony\Component\Validator\Constraints\Date)
.
When a user inputs a date with a five-digit year, the form is validated successfully but an incorrect date is persisted.
Example:
User inputs 20011-11-11
. Persisted date is 2001-11-11
.
It is probably not Symfony's fault, since PHP's DateTime('20011-11-11') indeed returns object(DateTime)#1 (3) { ["date"]=> string(26) "2001-11-11 20:01:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
. See http://3v4l.org/tCrGl for version details.
20011-11-11
should either be accepted as valid or rejected as invalid but not transformed to something else and accepted... Could Symfony validate the string format before PHP transforms it to a date?
Best regards