Permalink
Browse files

Merge branch 'hotfix/2290' into develop

Fix for #2290
  • Loading branch information...
2 parents 14737f3 + daa214f commit b5f50bae508e8a338b2b518a265909a2f60f17d0 @weierophinney weierophinney committed Sep 20, 2012
Showing with 22 additions and 2 deletions.
  1. +6 −2 library/Zend/Form/View/Helper/FormRow.php
  2. +16 −0 tests/ZendTest/Form/View/Helper/FormRowTest.php
@@ -121,13 +121,17 @@ public function render(ElementInterface $element)
$labelClose = $labelHelper->closeTag();
}
+ if ($label !== '') {
+ $label = '<span>' . $label . '</span>';
+ }
+
switch ($this->labelPosition) {
case self::LABEL_PREPEND:
- $markup = $labelOpen . '<span>' . $label . '</span>' . $elementString . $labelClose;
+ $markup = $labelOpen . $label . $elementString . $labelClose;
break;
case self::LABEL_APPEND:
default:
- $markup = $labelOpen . $elementString . '<span>' . $label . '</span>' . $labelClose;
+ $markup = $labelOpen . $elementString . $label . $labelClose;
break;
}
@@ -257,4 +257,20 @@ public function testSetLabelAttributes()
$this->helper->setLabelAttributes(array('foo', 'bar'));
$this->assertEquals(array(0 => 'foo', 1 => 'bar'), $this->helper->getLabelAttributes());
}
+
+ public function testWhenUsingIdAndLabelBecomesEmptyRemoveSpan()
+ {
+ $element = new Element('foo');
+ $element->setLabel('The value for foo:');
+
+ $markup = $this->helper->__invoke($element);
+ $this->assertContains('<span', $markup);
+ $this->assertContains('</span>', $markup);
+
+ $element->setAttribute('id', 'foo');
+
+ $markup = $this->helper->__invoke($element);
+ $this->assertNotContains('<span', $markup);
+ $this->assertNotContains('</span>', $markup);
+ }
}

0 comments on commit b5f50ba

Please sign in to comment.