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

Skip to content

[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

Merged
merged 1 commit into from
Dec 5, 2015
Merged

Conversation

nicolas-grekas
Copy link
Member

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #16792
License MIT
Doc PR -

@stof
Copy link
Member

stof commented Dec 2, 2015

@nicolas-grekas this still does not fix the case of null for types loading choices in a different way (even though they should probably change the default for choices_as_values in this case, avoiding the issue)

@piogrek
Copy link

piogrek commented Dec 2, 2015

@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

@@ -263,9 +263,11 @@ public function configureOptions(OptionsResolver $resolver)
return $choices;
}

ChoiceType::normalizeLegacyChoices($choices, $choiceLabels);
if (null === $choices) {
$choices = array();
Copy link
Member Author

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

Copy link
Member

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)

@mbabker
Copy link
Contributor

mbabker commented Dec 3, 2015

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.

@stof
Copy link
Member

stof commented Dec 5, 2015

👍

1 similar comment
@fabpot
Copy link
Member

fabpot commented Dec 5, 2015

👍

@stof
Copy link
Member

stof commented Dec 5, 2015

Thanks for fixing this bug @nicolas-grekas.

@stof stof merged commit 021d93a into symfony:2.8 Dec 5, 2015
stof added a commit that referenced this pull request Dec 5, 2015
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
@nicolas-grekas nicolas-grekas deleted the fixchoice branch December 5, 2015 12:00
This was referenced Dec 26, 2015
@Tobion
Copy link
Contributor

Tobion commented Dec 29, 2015

Shouldn't this have been merged in 2.7? See #17163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants