I've added a element to my form which is of type 'date', this then has a validation rule which specifies that the form element value must be of type date, otherwise return an error. However rather than handling the validation, Symfony returns an Exception. See code below:
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 that Symfony will notice the value is not in the right format and handle the error as specified, instead I get this
Failed to match value '2007-01-aaa' with pattern 'yyyy-MM-dd'
500 Internal Server Error - InvalidArgumentException
Am I doing something wrong here?
Thanks in advance
It's a bug. It's now fixed and merged into 2.0 branch . It'll be hopefully included in next minor version.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.