-
-
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.
| 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.
| 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.
| 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 |
…by int ID (webmozart) This PR was merged into the 2.7 branch. Discussion ---------- [Form] Fixed: Filter non-integers when selecting entities by int ID | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14583 (for Doctrine, not Propel) | License | MIT | Doc PR | - This PR fixes #14583 for Doctrine. Non-integer values (like `""`) are not passed to the database anymore when selecting entities by integer PK, which causes an error on some DBMSs (like PostgreSQL). Commits ------- 352be8e [Form] Fixed: Filter non-integers when selecting entities by int ID
I just found this issue since I'm getting exactly this problem, but with |
This PR was squashed before being merged into the 2.3 branch (closes #17668). Discussion ---------- add 'guid' to list of exception to filter out | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14583 | License | MIT | Doc PR | none See #14583 (comment) Commits ------- 0de86ff add 'guid' to list of exception to filter out
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: