-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] fix problems when the field values are Boolean #17755
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
@be-bewweb please, update the description of your pull request to add the checklist as explained here: http://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request Thanks! |
If this fixes a bug, please also add a test to avoid future regressions. |
Where can I add the test ? Sorry but this is the first time I do a pull request. Thanks for your help |
@be-bewweb The tests for the Form component are stored under the |
@be-bewweb the issue is that choices in your case are not So IMO, this PR is invalid. |
@@ -344,7 +344,7 @@ public function setData($modelData) | |||
} | |||
|
|||
// Treat data as strings unless a value transformer exists | |||
if (!$this->config->getViewTransformers() && !$this->config->getModelTransformers() && is_scalar($modelData)) { | |||
if (!$this->config->getViewTransformers() && !$this->config->getModelTransformers() && !is_bool($modelData) && is_scalar($modelData)) { |
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 should replace the scalar check by a string check instead of testing a non-bool.
wrong forget it.
Hi @be-bewweb, could you please update to 2.7.10 and confirm your issue before moving on with this PR ? This bug may have been fixed by #17760. |
ping @be-bewweb :) |
Closing this as the bug is in the code written by the user. Booleans cannot be used as array keys in PHP, as I said above. |
Problem
When the field values are Boolean as below, false value is not shown.
class RadioYesNoType extends AbstractType