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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aivus opened this issue Dec 14, 2016 · 1 comment
Closed

[Form] ChoiceType is valid in case of TransformationFailedException #20916

aivus opened this issue Dec 14, 2016 · 1 comment

Comments

@aivus
Copy link
Contributor
aivus commented Dec 14, 2016
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?

@HeahDude
Copy link
Contributor

@aivus Thanks for reporting this, I agree, see #20966.

@xabbuh xabbuh removed the Unconfirmed label Jan 6, 2017
@fabpot fabpot closed this as completed Nov 12, 2018
fabpot added a commit that referenced this issue Nov 12, 2018
This PR was merged into the 2.8 branch.

Discussion
----------

[Form] invalidate forms on transformation failures

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20916, #21242, #28584
| License       | MIT
| Doc PR        |

Commits
-------

385d9df invalidate forms on transformation failures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
0