8000 [FrameworkBundle] Rendering value "0" in checkboxes · Issue #8251 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

[FrameworkBundle] Rendering value "0" in checkboxes #8251

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

Closed
rejinka opened this issue Jun 12, 2013 · 1 comment
Closed

[FrameworkBundle] Rendering value "0" in checkboxes #8251

rejinka opened this issue Jun 12, 2013 · 1 comment
Labels

Comments

@rejinka
Copy link
rejinka commented Jun 12, 2013
<input type="checkbox"
    <?php echo $view['form']->block($form, 'widget_attributes') ?>
    <?php if ($value): ?> value="<?php echo $view->escape($value) ?>"<?php endif ?>
    <?php if ($checked): ?> checked="checked"<?php endif ?>
/>

That is the content of "checkbox_widget.html.php". It is easy to see, that the value is only rendered if($value). Since "0" == true => false, the index 0 is not possible in checkboxes. As i think "0" is a reasonable value and therefore expected to work, this should be changed. Could be

if ($value || '0' === $value)

Something better does not get in my mind, yet.

If you try to use a "choice" like in the choice type (and expanded = true)

[
  0 => 'a',
  1 => 'b',
  2 => 'c'
]

checking "a" won't be recognized and checking "b" will end in an cryptic error.

@rejinka
Copy link
Author
rejinka commented Jun 16, 2013

Okay, i am now trying to render an integer-type and "0" makes the value disappear - not that nice

fabpot added a commit that referenced this issue Dec 6, 2013
…mplates (jakzal)

This PR was merged into the 2.3 branch.

Discussion
----------

[FrameworkBundle] Allowed "0" as a checkbox value in php templates

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

Commits
-------

955e8cf [FrameworkBundle] Allowed "0" as a checkbox value in the php template.
@fabpot fabpot closed this as completed Dec 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants
0