Permalink
Browse files

Merge pull request #4582 from noopable/hotfix/nested-form-elementsnam…

…e-wrapping

Fix Nested form element wrapping (relative: #4383)
  • Loading branch information...
2 parents 31fa35b + cc3236d commit 57882ad540c5ef0b724ff3b20198135547496fd0 @weierophinney weierophinney committed Jun 11, 2013
Showing with 18 additions and 1 deletion.
  1. +3 −1 library/Zend/Form/Form.php
  2. +15 −0 tests/ZendTest/Form/FormTest.php
View
4 library/Zend/Form/Form.php
@@ -177,7 +177,9 @@ public function prepare()
$this->prepareElement($this);
} else {
foreach ($this->getIterator() as $elementOrFieldset) {
- if ($elementOrFieldset instanceof ElementPrepareAwareInterface) {
+ if ($elementOrFieldset instanceof FormInterface) {
+ $elementOrFieldset->prepare();
+ } elseif ($elementOrFieldset instanceof ElementPrepareAwareInterface) {
$elementOrFieldset->prepareElement($this);
}
}
View
15 tests/ZendTest/Form/FormTest.php
@@ -1527,4 +1527,19 @@ public function testAddRemove()
$this->form->remove('file_resource');
$this->assertEquals($form, $this->form);
}
+
+ public function testNestedFormElementNameWrapping()
+ {
+ //build form
+ $rootForm = new Form;
+ $leafForm = new Form('form');
+ $element = new Element('element');
+ $leafForm->setWrapElements(true);
+ $leafForm->add($element);
+ $rootForm->add($leafForm);
+
+ //prepare for view
+ $rootForm->prepare();
+ $this->assertEquals('form[element]', $element->getName());
+ }
}

0 comments on commit 57882ad

Please sign in to comment.