Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[2.7] [Form] fix choice value "false" in ChoiceType#17760
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
xabbuh commentedFeb 11, 2016
👍 Status: Reviewed ping @symfony/deciders |
fabpot commentedFeb 12, 2016
👍 |
webdevilopers commentedFeb 12, 2016
Fix works! 👍 |
Tobion commentedFeb 12, 2016
This fix contradictshttps://github.com/symfony/symfony/pull/16681/files#r45997531 Please add a test for that (which would currently fail AFAIK): null and false should not conflict and thus can both be used as |
Tobion commentedFeb 12, 2016
Btw, this would fix |
Tobion commentedFeb 12, 2016
So basically we need to map all scalars that would result in an empty string to something else to not conflict we the placeholder: I would propose this mapping:
And if there are still conflicts e.g. because someone has both |
HeahDude commentedFeb 13, 2016
Thanks@Tobion for the review. You're right, I'm fixing it. Status: Needs Work |
HeahDude commentedFeb 13, 2016
Tests are fixed. Status: Needs Review |
Tobion commentedFeb 13, 2016
The problem now is will not add the placeholder anymore because |
HeahDude commentedFeb 13, 2016
@Tobion, thanks again for the heads-up, so I keep on testing. Status: Needs Work |
… `choices_as_values` (HeahDude)This PR was squashed before being merged into the 3.0 branch (closes#17886).Discussion----------[WIP] [3.0] [Form] fix tests added by#17760 by removing `choices_as_values`| Q | A| ------------- | ---| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | not yet| Fixed tickets | n/a| License | MIT| Doc PR | -- [x] Wait for#17760 being merged in 3.0Commits-------03a7705 [WIP] [3.0] [Form] fix tests added by#17760 by removing
…ahDude)This PR was merged into the 2.8 branch.Discussion----------[WIP] [2.8] [Form] fix FQCN in tests added by#17760| Q | A| ------------- | ---| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | not yet| Fixed tickets | n/a| License | MIT| Doc PR | -- [x] Update tests from#17760- [x] Wait for#17760 to be merged in 2.8Commits-------acdd7db [Form] fix tests added by#17760 with FQCN
* 2.8: [Form] fix tests added by#17760 with FQCN
* 3.0:#17676 - making the proxy instantiation compatible with ProxyManager 2.x by detecting proxy features#17676 - making the proxy instantiation compatible with ProxyManager 2.x by detecting proxy features Fix bug when using an private aliased factory service [Form] fix tests added by#17798 by removing `choices_as_values` [Form] fix FQCN in tests added by#17798 [DependencyInjection] Remove unused parameter of private property bug#17798 [Form] allow `choice_label` option to be `false` [Form] fix tests added by#17760 with FQCN ChoiceFormField of type "select" could be "disabled" Update contributing docs [Console] Fix escaping of trailing backslashes Fix constraint validator alias being required [DependencyInjection] Simplified code in AutowirePass [ci] clone with depth=1 to kill push-forced PRs Add check on If-Range header
Taluu commentedFeb 29, 2016
This seems to break API ways on Symfony 2.8.3. When before I could do the following : <?phpclass ChoiceTypeextends AbstractType{publicfunctionbuildForm(FormBuilderInterface$builder,array$options) {$builder->add('status', ChoiceType::class, ['choices' => [true,false,'true','false'],'choices_as_values' =>true ]); }} With the following json sent data : {"choices":[ {"hash":"foo4u","label":"foo","status":true }, {"hash":"bar4u","label":"bar","status":"false" }, {"hash":"baz4u","label":"baz","status":false } ]}whilre before I could use the values |
Taluu commentedFeb 29, 2016
And when I change the order in the |
HeahDude commentedFeb 29, 2016
@Taluu, The submission of a If you submit a true value it will be cast to string so So If there is
Another way to resolve this is to return false in You can rely on |
Taluu commentedFeb 29, 2016
For legacy reason we have these Until then, we will have to stick with |
HeahDude commentedFeb 29, 2016
Edge case then. Happy coding :) |
Taluu commentedFeb 29, 2016
Yep, I confirm, this is indeed due to this. Don't know if it was there or not before, but using a And using directly the |
HeahDude commentedFeb 29, 2016
@Taluu, note that the That's why it messes with PATCH method and When you need to use |
webmozart commentedMar 2, 2016
@Taluu You could preprocess your request data and postprocess your responses to transform Booleans to strings and back. That would at least fix your API. |
…ChoiceType` and its children (HeahDude)This PR was merged into the 2.7 branch.Discussion----------[Form] fixed BC break with pre selection of choices with `ChoiceType` and its children| Q | A| ------------- | ---| Branch | 2.7+| Bugfix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#18173,#14712,#17789| License | MIT| Doc PR | --f7eea72 reverts BC break introduced in#17760-58e8ed0 fixes pre selection of choice with model values such as `false`, `null` or empty string without BC break.`ChoiceType` now always use `ChoiceToValueTransformer` or `ChoicesToValuesTransformer` depending on `multiple` option.Hence `CheckboxListMapper` and `RadioListMapper` don't handle the transformation anymore.Commits-------ea5375c [Form] refactor CheckboxListMapper and RadioListMapper71841c7 Revert "[Form] refactor `RadioListMapper::mapDataToForm()`"
booleanandnullvalues, and with a placeholderchoices_as_valuesin 3.0 tests, see[WIP] [3.0] [Form] fix tests added by #17760 by removingchoices_as_values#17886