Skip to content

[Form] DateTimeToLocalizedStringTransformer - reverseTransform returns wrong \DateTime Object #20578

@Belgacem-TLILI

Description

@Belgacem-TLILI

Symfony 2.8.13

Below is my form date field

     $builder->add('my_date', array(
                'widget' => 'single_text',
                'attr' => array(
                    'class' => 'date-picker',
                    'size' => 10,
                ),
                'format' => 'dd-MM-yyyy',
                'required' => false,
                'input' => 'datetime',
                'constraints' => [
                    new GreaterThanOrEqual([
                        'value' => new \DateTime('01-01-2000'),
                        'message' => 'Invalid date value',
                    ]),
                    new LessThanOrEqual([
                        'value' => new \DateTime('31-12-9999'),
                        'message' => 'Invalid date value',
                    ]),
                ],
            )
        );

After last merge the constraints GreaterThanOrEqual and LessThanOrEqual are not working anymore as the DateTimeToLocalizedStringTransformer returns different value than the user input

below is the dump of the transformed value (submitted value is 01-01-20033)

screen shot 2016-11-21 at 4 00 53 pm

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions