Permalink
Browse files

Merge remote-tracking branch 'mwillbanks/hotfix/form-helper-formlabel…

…-optional-invoke'
  • Loading branch information...
2 parents 1ce29f1 + 029f4cb commit 2231834c7aea87e643c97d447dc5eb8f1bfb8713 @EvanDotPro EvanDotPro committed Jun 6, 2012
Showing with 13 additions and 1 deletion.
  1. +4 −1 library/Zend/Form/View/Helper/FormLabel.php
  2. +9 −0 tests/Zend/Form/View/Helper/FormLabelTest.php
View
5 library/Zend/Form/View/Helper/FormLabel.php
@@ -105,8 +105,11 @@ public function closeTag()
* @param string $position
* @return string
*/
- public function __invoke(ElementInterface $element, $labelContent = null, $position = null)
+ public function __invoke(ElementInterface $element = null, $labelContent = null, $position = null)
{
+ if (!$element) {
+ return $this;
+ }
$openTag = $this->openTag($element);
$label = false;
if (null === $labelContent || null !== $position) {
View
9 tests/Zend/Form/View/Helper/FormLabelTest.php
@@ -145,4 +145,13 @@ public function testPassingElementAndContextAndFlagToInvokeRaisesExceptionForMis
$this->setExpectedException('Zend\Form\Exception\DomainException', 'label');
$markup = $this->helper->__invoke($element, '<input type="text" id="foo" />', FormLabelHelper::APPEND);
}
+
+ public function testCallingFromViewHelperCanHandleOpenTagAndCloseTag()
+ {
+ $helper = $this->helper;
+ $markup = $helper()->openTag();
+ $this->assertEquals('<label>', $markup);
+ $markup = $helper()->closeTag();
+ $this->assertEquals('</label>', $markup);
+ }
}

0 comments on commit 2231834

Please sign in to comment.