4

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

1

1 Answer 1

1

It's a bug. It's now fixed and merged into 2.0 branch. It'll be hopefully included in next minor version.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.