-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Choice type int values (BC Fix) #21957
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
480d18c
to
4953631
Compare
4953631
to
be1c3a8
Compare
@@ -171,7 +171,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) | |||
} | |||
|
|||
foreach ($data as $v) { | |||
if (null !== $v && !is_string($v)) { | |||
if (null !== $v && !is_string($v) && !is_int($v)) { | |||
throw new TransformationFailedException('All choices submitted must be NULL or strings.'); |
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.
the message should be updated too
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.
Changed it.
be1c3a8
to
56e3974
Compare
56e3974
to
dad87f8
Compare
Thank you @mcfedr. |
This PR was squashed before being merged into the 2.7 branch (closes #21957). Discussion ---------- [Form] Choice type int values (BC Fix) | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21952 | License | MIT #21267 unnecessarily forced all choice values to be strings, this was a BC braking change. Everything can work fine if they are strings or ints. specifically the issue was because `array_flip` is used on the `choices` array, but this function will work fine with ints as well as strings. Normally, when using HTML forms all data comes as strings, but the `symfony/form` component has use cases beyond this, specifically, I use it with JSON data, where valid values for a `ChoiceType` might not be strings. Commits ------- ed211e9 [Form] Choice type int values (BC Fix)
Thank you @fabpot for Symfony :) |
This needs to land it 2.8 and 3.2 branches as well. |
Merged into 2.8 as well. For 3.2, I will let @nicolas-grekas do the merge |
- symfony 3.2.5/6で、choice typeでint値を受け付けなくなっていたため(symfony/symfony#21267) - 21267はbc break扱いで再度修正が入っている(symfony/symfony#21957) - symfony3.2.7で解消されると思われるが、テスト通したいので直しておく
Ping @nicolas-grekas - any ETA on the 3.2 merge? We're still locked to 3.2.4 here as a result of the issue. 😢 |
@superhaggis It's been merged a while ago. |
Or are you asking for a new release? In that case, that should be done very soon. |
@fabpot Yeah, I guess I'm asking for a new release. Thanks for the update. 😄 |
When will this fix be released in 3.2.*? Downgrading right now to 3.2.4 :( |
A new 3.2 version will probably be released today. |
…y/symfony#21267) - 21267はbc break扱いで再度修正が入っている(symfony/symfony#21957) - symfony3.2.7で解消されると思われるが、テスト通したいので直しておく
This PR was merged into the 2.7 branch. Discussion ---------- [Form] Minor: Fix comment in ChoiceType | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | n/a | Fixed tickets | n/a | License | MIT | Doc PR | n/a Forgotten to be updated in: #21957 Commits ------- a49d79c [Form] Minor: Fix comment in ChoiceType
#21267 unnecessarily forced all choice values to be strings, this was a BC braking change.
Everything can work fine if they are strings or ints. specifically the issue was because
array_flip
is used on thechoices
array, but this function will work fine with ints as well as strings.Normally, when using HTML forms all data comes as strings, but the
symfony/form
component has use cases beyond this, specifically, I use it with JSON data, where valid values for aChoiceType
might not be strings.