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

Commit

Permalink
Merge pull request zendframework#4771 from stefanotorresi/fix/form-ro…
Browse files Browse the repository at this point in the history
…w-label-position

Form\View\Helper\FormRow label position gets overwritten by __invoke()
  • Loading branch information
weierophinney committed Jul 2, 2013
2 parents 28889a5 + 922e659 commit 4862c47
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Form/View/Helper/FormRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function __invoke(ElementInterface $element = null, $labelPosition = null

if ($labelPosition !== null) {
$this->setLabelPosition($labelPosition);
} else {
} elseif ($this->labelPosition === null) {
$this->setLabelPosition(self::LABEL_PREPEND);
}

Expand Down
10 changes: 10 additions & 0 deletions tests/ZendTest/Form/View/Helper/FormRowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,14 @@ public function testAssertButtonElementDoesNotRenderLabelTwice()
$markup = $this->helper->render($element);
$this->assertRegexp('#^<button type="button" name="button" value=""\/?>foo</button>$#', $markup);
}

public function testCanSetLabelPositionBeforeInvoke()
{
$element = new Element('foo');

$this->helper->setLabelPosition('append');
$this->helper->__invoke($element);

$this->assertSame('append', $this->helper->getLabelPosition());
}
}

0 comments on commit 4862c47

Please sign in to comment.