I added an element to my form, which is of type 'date', then it has a validation rule that indicates that the value of the form element must have a type date, otherwise return an error. However, instead of processing the check, Symfony returns an exception. See the following code:
UserType.php
$builder->add('startdate', 'date', array( 'label' => 'Start Date', 'widget' => 'single_text', 'format' => 'yyyy-MM-dd') );
Validation.yml
Acme\StoreBundle\Entity\User: properties: startdate: - Date: message: You must specify a valid release date
Then, when I type '2001-01-aaa', hoping Symfony sees that the value is not in the correct format and handles the error as indicated, I get this instead
Failed to match value '2007-01-aaa' with pattern 'yyyy-MM-dd' 500 Internal Server Error - InvalidArgumentException
Am I doing something wrong here?
Thank you in advance
source share