Fix Nested form element wrapping (relative: #4383) #4582

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+18 −1
Split
@@ -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);
}
}
@@ -1519,4 +1519,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());
+ }
}