From 922e659e1b9c4b83f22088592c6809f81c75e71b Mon Sep 17 00:00:00 2001 From: Stefano Torresi Date: Tue, 2 Jul 2013 11:57:14 +0200 Subject: [PATCH] fix formRow label position being overwritten by __invoke() --- library/Zend/Form/View/Helper/FormRow.php | 2 +- tests/ZendTest/Form/View/Helper/FormRowTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/library/Zend/Form/View/Helper/FormRow.php b/library/Zend/Form/View/Helper/FormRow.php index 7b688c5a5b3..a4e358c9c78 100644 --- a/library/Zend/Form/View/Helper/FormRow.php +++ b/library/Zend/Form/View/Helper/FormRow.php @@ -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); } diff --git a/tests/ZendTest/Form/View/Helper/FormRowTest.php b/tests/ZendTest/Form/View/Helper/FormRowTest.php index 5ede594e32b..c27189d940f 100644 --- a/tests/ZendTest/Form/View/Helper/FormRowTest.php +++ b/tests/ZendTest/Form/View/Helper/FormRowTest.php @@ -372,4 +372,14 @@ public function testAssertButtonElementDoesNotRenderLabelTwice() $markup = $this->helper->render($element); $this->assertRegexp('#^$#', $markup); } + + public function testCanSetLabelPositionBeforeInvoke() + { + $element = new Element('foo'); + + $this->helper->setLabelPosition('append'); + $this->helper->__invoke($element); + + $this->assertSame('append', $this->helper->getLabelPosition()); + } }