-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Fix choices defined as Traversable #16796
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
Conversation
nicolas-grekas
commented
Dec 2, 2015
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #16792 |
License | MIT |
Doc PR | - |
@nicolas-grekas this still does not fix the case of |
@stof thanks for a hint I think that's the simplest way and EntityType already have it. Just found PR from last night (but it needs more thought) symfony/propel1-bridge#1 |
6b47cd5
to
d185f79
Compare
@@ -263,9 +263,11 @@ public function configureOptions(OptionsResolver $resolver) | |||
return $choices; | |||
} | |||
|
|||
ChoiceType::normalizeLegacyChoices($choices, $choiceLabels); | |||
if (null === $choices) { | |||
$choices = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof here is null
handling. But should we deprecate accepting the null
value? Otherwise, 3.0 misses a "choices" normalizer also, isn't it?
https://github.com/symfony/symfony/pull/16796/files#diff-11ee91a32c601e8e1d509117556d53b3R400
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolas-grekas some sub-types are using null
as default value of the option to distinguish between passing choices explicitly and using other ways of building choices (using the query builder). This change would break them (the PropelType for instance).
The Doctrine entity type is not affected because it changes the choices_as_values
default and so is not triggered this line of code.
IMO, if null
is given as input, you should just return it as is here (and letting the validation happening later checking this case in case the subtype does not handle it properly)
FWIW I ran into the same error condition in #16792 using a combination of the Form component 2.8 and Doctrine bridge 3.0 with the EntityType and this PR fixed the error for that case. |
d185f79
to
021d93a
Compare
👍 |
1 similar comment
👍 |
Thanks for fixing this bug @nicolas-grekas. |
This PR was merged into the 2.8 branch. Discussion ---------- [Form] Fix choices defined as Traversable | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16792 | License | MIT | Doc PR | - Commits ------- 021d93a [Form] Fix choices defined as Traversable
Shouldn't this have been merged in 2.7? See #17163 |