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

Fix for #2541 #2976

Closed
wants to merge 2 commits into from
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
5 changes: 3 additions & 2 deletions library/Zend/Form/Form.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -559,9 +559,10 @@ protected function prepareValidationGroup(FieldsetInterface $formOrFieldset, arr


$value = $values; $value = $values;
} else { } else {
if (isset($data[$key])) { if (!isset($data[$key])) {
$this->prepareValidationGroup($fieldset, $data[$key], $validationGroup[$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 Original file line Diff line number Diff line change
Expand Up @@ -1025,6 +1025,34 @@ public function testRemoveCollectionFromValidationGroupWhenZeroCountAndNoData()
$this->assertTrue($this->form->isValid()); $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() public function testApplyObjectInputFilterToBaseFieldsetAndApplyValidationGroup()
{ {
$fieldset = new Fieldset('foobar'); $fieldset = new Fieldset('foobar');
Expand Down