Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/2290' into develop
Browse files Browse the repository at this point in the history
Fix for #2290
  • Loading branch information
weierophinney committed Sep 20, 2012
2 parents 14737f3 + daa214f commit b5f50ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 6 additions & 2 deletions library/Zend/Form/View/Helper/FormRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
16 changes: 16 additions & 0 deletions tests/ZendTest/Form/View/Helper/FormRowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.