-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[form] error when submitting empty value in for using model choice list #14583
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
Comments
Fixed in #14465 I guess. |
It was fixed partially. but in our case exception happens in ModelChoiceList , before the null/empty check in ChoiceToValueTransformer. still not fixed, but I can't re-open this ticket now |
Same error after submitting optional entity form field type with empty_value with doctrine on Symfony 2.7 (e60f715). Related issues are #14393 and #14465, but non of those fixes seems to fix this issue. Field definition: $builder->add('dealer', 'entity', array(
'label' => 'useraccount.label.dealer',
'class' => 'MyAppBundle:Subject',
'choice_label' => 'label',
'empty_value' => '',
'multiple' => false,
'required' => false
)); After submitting empty value i get this error:
It seems like Symfony is trying to find Subject entity using empty string as id for dealer field:
|
Seems to be the same problem, but fix needs to be done either in ChoiceToValueTransformer (for both model and entity lists) or separately in bridge ChoiceList classes |
| Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#14583 | License | MIT | Doc PR | Fixes symfony#14583.
+1
If in this case i try save empty value, i have error
If set 'empty_data' => 0,
worked without errors Symfony version 2.7.0-DEV |
@madmis by trying this workaround I get an TransformationFailureException "The choice "0" does not exist or is not unique" and it break my form validation Symfony 2.7.0 LTS |
This happens for me with the
|
This bug is fixed for Doctrine in #14950. |
That fix solves my issue... although it feels somehow hacky to just filter any non-integers from the values. Shouldn't it be fixed somehow related to |
I just found this issue since I'm getting exactly this problem, but with |
I think that's happening only on propel + postgres after @webmozart removed empty/null checks from ChoiceToValueTransformer in 1d89922
ModelChoiceList->getChoicesForValues allows to create Propel query with empty string values which are not accepted, so I'm getting:
the code below (for propel bridge) seems to do the trick, but I'm not sure if I can create PR for the Propel1Bridge repository. Will appreciate any help.
The text was updated successfully, but these errors were encountered: