Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions library/Zend/Form/Fieldset.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@ public function allowValueBinding()
*/
public function bindValues(array $values = array())
{
$objectData = $this->extract();
$hydrator = $this->getHydrator();
$hydratableData = array();

Expand All @@ -588,8 +587,6 @@ public function bindValues(array $values = array())
// skip post values for disabled elements, get old value from object
if(!$element->hasAttribute('disabled')) {
$hydratableData[$name] = $value;
} elseif(array_key_exists($name, $objectData)) {
$hydratableData[$name] = $objectData[$name];
}
}

Expand Down
24 changes: 24 additions & 0 deletions tests/ZendTest/Form/FieldsetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Zend\Form\Form;
use Zend\Form\Fieldset;
use Zend\InputFilter\InputFilter;
use Zend\Stdlib\Hydrator;

class FieldsetTest extends TestCase
{
Expand Down Expand Up @@ -522,4 +523,27 @@ public function testShouldValidateAllowObjectBindingByObject()
$this->assertTrue($allowed);
}

/**
* @group 6645
*/
public function testBindValuesPreservesNewValueAfterValidation()
{
$form = new Form();
$form->add(new Element('foo'));
$form->setHydrator(new Hydrator\ObjectProperty);

$object = new \stdClass();
$object->foo = 'Initial value';
$form->bind($object);

$form->setData(array(
'foo' => 'New value'
));

$this->assertSame('New value', $form->get('foo')->getValue());

$form->isValid();

$this->assertSame('New value', $form->get('foo')->getValue());
}
}