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

Commit

Permalink
Merge branch 'hotfix/7109' into develop
Browse files Browse the repository at this point in the history
Forward port #7109
  • Loading branch information
weierophinney committed Jan 13, 2015
2 parents ca2485a + e0684ef commit 3838f37
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Form/Fieldset.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ public function bindValues(array $values = array())
}

// skip post values for disabled elements, get old value from object
if (!$element->hasAttribute('disabled')) {
if (!$element->getAttribute('disabled')) {
$hydratableData[$name] = $value;
} elseif (array_key_exists($name, $objectData)) {
$hydratableData[$name] = $objectData[$name];
Expand Down
25 changes: 25 additions & 0 deletions tests/ZendTest/Form/FieldsetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,31 @@ public function testBindValuesSkipDisabled()
$this->assertEquals('notModified', $object->disabled);
}

/**
* @group 7109
*/
public function testBindValuesDoesNotSkipElementsWithFalsyDisabledValues()
{
$object = new \stdClass();
$object->disabled = 'notModified';
$object->not_disabled = 'notModified';

$textInput = new Element\Text('not_disabled');
$disabledInput = new Element\Text('disabled');
$disabledInput->setAttribute('disabled', '');

$form = new Form();
$form->add($textInput);
$form->add($disabledInput);

$form->setObject($object);
$form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty());
$form->bindValues(array('not_disabled' => 'modified', 'disabled' => 'modified'));

$this->assertEquals('modified', $object->not_disabled);
$this->assertEquals('modified', $object->disabled);
}

public function testSetObjectWithStringRaisesException()
{
$this->setExpectedException('Zend\Form\Exception\InvalidArgumentException');
Expand Down

0 comments on commit 3838f37

Please sign in to comment.