diff --git a/library/Zend/Form/View/Helper/FormCollection.php b/library/Zend/Form/View/Helper/FormCollection.php index bd036a65e96..30a389dff49 100644 --- a/library/Zend/Form/View/Helper/FormCollection.php +++ b/library/Zend/Form/View/Helper/FormCollection.php @@ -118,12 +118,16 @@ public function render(ElementInterface $element) $label = $escapeHtmlHelper($label); - $markup = sprintf( - '
', - $label, - $markup - ); + $labelMarkup = sprintf('', $label); + } else { + $labelMarkup = ''; } + + $markup = sprintf( + '', + $labelMarkup, + $markup + ); } return $markup; diff --git a/tests/ZendTest/Form/View/Helper/FormCollectionTest.php b/tests/ZendTest/Form/View/Helper/FormCollectionTest.php index a2b4f6d7a49..21ff9a16375 100644 --- a/tests/ZendTest/Form/View/Helper/FormCollectionTest.php +++ b/tests/ZendTest/Form/View/Helper/FormCollectionTest.php @@ -176,4 +176,15 @@ public function testCanTranslateLegend() $this->assertContains('>translated legend<', $markup); } + + public function testShouldWrapWithoutLabel() + { + $form = $this->getForm(); + $collection = $form->get('colors'); + $collection->setLabel(''); + $this->helper->setShouldWrap(true); + + $markup = $this->helper->render($collection); + $this->assertContains('