8000 [Form] ChoiceType is valid in case of TransformationFailedException · Issue #20916 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[Form] ChoiceType is valid in case of TransformationFailedException #20916
Closed
@aivus

Description

@aivus
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 2.8.11

Hello.

Is it ok, when incorrect data submitted to ChoiceType and isValid returns true?

        $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
            'expanded' => true
            'choices' => [
                    'a' => 'a',
                    'b' => 'b'
            ],
        ));

        $form->submit('c');
        $form->isValid(); // returns true
        $form->isSynchronized(); // returns false
        $form->getData(); // returns null

It actually strange that this submission is valid.
It happens because ChoiceType throws TransformationFailedException on PRE_SUBMIT event.

I think in this case isValid should return false.
What do you think?

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

      0