Skip to content

Commit

Permalink
Merge branch 'hotfix/2976'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Nov 19, 2012
2 parents fea78d5 + 224d910 commit 880807f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
5 changes: 3 additions & 2 deletions library/Zend/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,10 @@ protected function prepareValidationGroup(FieldsetInterface $formOrFieldset, arr

$value = $values;
} else {
if (isset($data[$key])) {
$this->prepareValidationGroup($fieldset, $data[$key], $validationGroup[$key]);
if (!isset($data[$key])) {
$data[$key] = array();
}
$this->prepareValidationGroup($fieldset, $data[$key], $validationGroup[$key]);
}
}
}
Expand Down
28 changes: 28 additions & 0 deletions tests/ZendTest/Form/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,34 @@ public function testRemoveCollectionFromValidationGroupWhenZeroCountAndNoData()
$this->assertTrue($this->form->isValid());
}

public function testFieldsetValidationGroupStillPreparedWhenEmptyData()
{
$emptyData = array();

$this->populateForm();
$this->form->get('foobar')->add(array(
'type' => 'Zend\Form\Element\Collection',
'name' => 'categories',
'options' => array(
'count' => 0,
'target_element' => array(
'type' => 'ZendTest\Form\TestAsset\CategoryFieldset'
)
)
));

$this->form->setValidationGroup(array(
'foobar' => array(
'categories' => array(
'name'
)
)
));

$this->form->setData($emptyData);
$this->assertFalse($this->form->isValid());
}

public function testApplyObjectInputFilterToBaseFieldsetAndApplyValidationGroup()
{
$fieldset = new Fieldset('foobar');
Expand Down

0 comments on commit 880807f

Please sign in to comment.