Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix bad radio and checkboxes values binding in case of booleans #771

merged 1 commit into from Dec 31, 2012


None yet
2 participants

mehlah commented Dec 31, 2012

In case of a false field value, the bindings for radio and checkboxes breaks, because of the second part of this condition, which is evaluated to false.

if (!isset($options['checked']) && ($bound = $this->binding($name)->data)) {
    $options['checked'] = ($bound == $default);

This PR adds a couple of test cases to show that, and fix the condition for both radio() and checkbox() Form helper methods

@mehlah mehlah commented on the diff Dec 31, 2012

@@ -396,8 +396,19 @@ public function testCheckboxGeneration() {
$this->assertTags($result, array(
array('input' => array('type' => 'hidden', 'value' => '', 'name' => 'foo')),
array('input' => array(
- 'type' => 'checkbox', 'value' => '1', 'name' => 'foo',
- 'checked' => 'checked', 'id' => 'MockFormPostFoo'
+ 'type' => 'checkbox', 'value' => '1', 'name' => 'foo', 'id' => 'MockFormPostFoo',
+ 'checked' => 'checked'
+ ))

mehlah Dec 31, 2012


Code symmetry or easier reading

@nateabele nateabele added a commit that referenced this pull request Dec 31, 2012

@nateabele nateabele Merge pull request #771 from mehlah/fix-radio-bindings
Fix bad radio and checkboxes values binding in case of booleans

@nateabele nateabele merged commit 0bb714a into UnionOfRAD:dev Dec 31, 2012

1 check passed

default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment