Index: tests/Zend/Form/FormTest.php =================================================================== --- tests/Zend/Form/FormTest.php (revision 18652) +++ tests/Zend/Form/FormTest.php (working copy) @@ -1329,6 +1329,34 @@ $this->assertEquals($subForm->foo->getValue(), $values['subform']['foo']); $this->assertEquals($subForm->bar->getValue(), $values['subform']['bar']); } + + public function testGetValuesReturnsSubFormValuesFromArrayToWhichElementsBelongUsingArrayNotation() + { + $subForm1 = new Zend_Form_SubForm(); + $subForm1->addElements(array('foo' => 'text', 'bar' => 'text'))->setElementsBelongTo('subform[0]'); + $subForm1->foo->setValue('foo value'); + $subForm1->bar->setValue('bar value'); + $this->form->addSubForm($subForm1, 'subform0'); + + $subForm2 = new Zend_Form_SubForm(); + $subForm2->addElements(array('foo' => 'text', 'bar' => 'text'))->setElementsBelongTo('subform[1]'); + $subForm2->foo->setValue('foo value'); + $subForm2->bar->setValue('bar value'); + $this->form->addSubForm($subForm2, 'subform1'); + + $values = $this->form->getValues(); + $this->assertEquals(2, count($values['subform'])); + $this->assertTrue(isset($values['subform'][0]), var_export($values, 1)); + $this->assertTrue(isset($values['subform'][0]['foo'])); + $this->assertTrue(isset($values['subform'][0]['bar'])); + $this->assertEquals($subForm1->foo->getValue(), $values['subform'][0]['foo']); + $this->assertEquals($subForm1->bar->getValue(), $values['subform'][0]['bar']); + $this->assertTrue(isset($values['subform'][1]), var_export($values, 1)); + $this->assertTrue(isset($values['subform'][1]['foo'])); + $this->assertTrue(isset($values['subform'][1]['bar'])); + $this->assertEquals($subForm2->foo->getValue(), $values['subform'][1]['foo']); + $this->assertEquals($subForm2->bar->getValue(), $values['subform'][1]['bar']); + } public function testGetValuesReturnsNestedSubFormValuesFromArraysToWhichElementsBelong() { Index: library/Zend/Form.php =================================================================== --- library/Zend/Form.php (revision 18652) +++ library/Zend/Form.php (working copy) @@ -1305,7 +1305,7 @@ } foreach ($this->getSubForms() as $key => $subForm) { $fValues = $this->_attachToArray($subForm->getValues(true), $subForm->getElementsBelongTo()); - $values = array_merge($values, $fValues); + $values = array_merge_recursive($values, $fValues); } if (!$suppressArrayNotation && $this->isArray()) {