Permalink
Browse files

Merge branch 'hotfix/2976' into develop

Forward port #2976
  • Loading branch information...
2 parents 2e7d402 + 224d910 commit a4a69e64865f50ab805ed60bd75c6fbf0cedab8b @weierophinney weierophinney committed Nov 19, 2012
Showing with 31 additions and 2 deletions.
  1. +3 −2 library/Zend/Form/Form.php
  2. +28 −0 tests/ZendTest/Form/FormTest.php
@@ -563,9 +563,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]);
}
}
}
@@ -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');

0 comments on commit a4a69e6

Please sign in to comment.