Skip to content

[Form] Binding false to a checkbox makes the checkbox being checked by default #7139

Closed
@vmattila

Description

@vmattila

I am not sure about whether this is a bug or by design: if a checkbox is bound to a boolean FALSE value, the checkbox is checked by default.

Failing test case:

    public function testBindWithFalseValueUnchecked()
    {
        $form = $this->factory->create('checkbox', null, array(
            'value' => '1',
        ));
        $form->bind(false);

        $this->assertFalse($form->getData());
        $view = $form->createView();
        $this->assertFalse($view->vars['checked']);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementFormGood first issueIdeal for your first contribution! (some Symfony experience may be required)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions