Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Allow Zend\Form\Element\Checkbox to return real value instead of always a boolean #4529

Closed
wants to merge 2 commits into from

Conversation

sjuvonen
Copy link
Contributor

This PR will fix the way Zend's Checkbox element handles values. The Checkbox element allows us to set any value as checked/unchecked value via setCheckedValue() and setUncheckedValue(). The default value is (string) 1 for checked state.

The bug is that currently Checkbox will not follow these values based on its check state. Instead Checkbox::getValue() always returns a boolean true/false. After this patch Checkbox will return the value of getUncheckedValue() when isChecked() return false and value of getCheckedValue() when isChecked() returns true.

I also updated the ZendTest\Form\Element\CheckboxTest::testSetAttributeValue() to cover these other use-cases.

weierophinney added a commit that referenced this pull request May 23, 2013
Allow Zend\Form\Element\Checkbox to return real value instead of always a boolean
weierophinney added a commit that referenced this pull request May 23, 2013
@weierophinney
Copy link
Member

Thanks for this, @sjuvonen -- this was the intended behavior, but never tested and verified, obviously!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants