-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Reverted string expectation in ChoiceToValueTransformer #18462
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
walczakmac
commented
Apr 6, 2016
Q | A |
---|---|
Branch? | 3.0 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #18461 |
License | MIT |
Doc PR | n/a |
@@ -78,10 +78,8 @@ public function testReverseTransform($in, $out, $inWithNull, $outWithNull) | |||
public function reverseTransformExpectsStringOrNullProvider() |
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.
You also need to rename those functions with *ExpectsScalarOrNull*
.
See also #17760 (comment) for a reason to not revert that change. |
Another reason would be consistency with the $builder->add('emailNotificationsEnabled', ChoiceType::class, [
'required' => false,
'multiple' => false,
'choices' => [0, 1],
'empty_data' => 1, // works If we revert by merging this PR
]);
$builder->add('emailNotificationsEnabled', ChoiceType::class, [
'required' => false,
'multiple' => true, // ChoicesToValuesTransformer will be called
'choices' => [0, 1],
'empty_data' => array(1), // won't work it expects array of strings array('1')
]); |
And |
Also consider that: $builder->add('emailNotificationsEnabled', ChoiceType::class, [
'required' => false,
'multiple' => false,
'choices' => [null, 0, 1],
'empty_data' => 1, // will match 0, needs the key '2' to match 1
]); |
Note that if accepted, this PR should be merged in 2.7. |
Now I see that there are too many cons when reverting it to previous state, and it will be much easier if I use strings there instead of integers. I'll just close the PR and the ticket, also thanks for your help @HeahDude. |
No worry ;) Thank you for the report. |