Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] unintended validation BC break by #14050 #14165

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
craue opened this issue Apr 1, 2015 · 8 comments
Closed

[Form] unintended validation BC break by #14050 #14165

craue opened this issue Apr 1, 2015 · 8 comments
Labels

Comments

@craue
Copy link
Contributor

craue commented Apr 1, 2015

#14050 seems to inadvertently affect validation. When submitting an empty required choice field, there's now a message "This value is not valid." which wasn't there before. See #14050 (comment).

@webmozart
Copy link
Contributor

Could you please post some code to reproduce this issue? Preferably a clone of symfony-standard?

craue added a commit to craue/symfony-standard that referenced this issue Apr 1, 2015
@craue
Copy link
Contributor Author

craue commented Apr 1, 2015

@webmozart: Done in https://github.com/craue/symfony-standard/tree/2.7-symfony-issue-14165.

Pre-PR (using "symfony/symfony": "2.7.x-dev#ef886548a0b6d1467876a60ef8f2c0f1e5a3ac3c") the error message is "This value should not be blank.", caused by the NotBlank annotation in the entity.

Post-PR (using "symfony/symfony": "2.7.x-dev#776796435e9f09cdb1b3afd71df2bff9b89d0c36") it's "This value is not valid.", making validation fail at some other point.

@webmozart
Copy link
Contributor

Thanks, I can confirm this. The reason is that ChoiceToValueTransformer::reverseTransform() originally returned null if either an empty string or null were passed, but without asking the choice list first. That was buggy in the case that you mapped the empty string to a custom choice, so I removed that check.

We need to find some other solution to allow empty strings if (i) the placeholder is enabled and (ii) the choice list does not already contain a choice with an empty string as value.

@samvaughton
Copy link

I'm also getting this. For an entity form type that is not required by default it will cause a SQL error due to an empty string "" being passed in the WHERE IN (?) clause.

If the empty_data is 0 then the query runs how it should but displays the "This value is not valid" message since no entity exists with id 0.

This stops any form from having optional entity form types.

@ngodfraind
Copy link

Any idea for a workaround ?

@adam187
Copy link

adam187 commented May 5, 2015

@ngodfraind #14465

@ngodfraind
Copy link

Thanks

@craue
Copy link
Contributor Author

craue commented May 5, 2015

It's fixed by #14465. Thank you, @webmozart.

@craue craue closed this as completed May 5, 2015
nobuhiko added a commit to nobuhiko/ec-cube that referenced this issue Jun 22, 2015
nobuhiko added a commit to nobuhiko/ec-cube that referenced this issue Jun 22, 2015
fix bugs TwigTrait
- add Test TwigTrait
- add Silex\Provider\HttpFragmentServiceProvider()
fix bugs autoload.php

precision -> scale
scale の引数はint only
http://symfony.com/blog/new-in-symfony-2-7-form-and-validator-updates

entity maps => false
http://symfony.com/doc/current/reference/forms/types/entity.html#mapped

多分これが原因
skip bugs
symfony/symfony#14165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants