Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #5931 from ThaDafinser/patch-6

Disable <label> for input hidden

Conflicts:
	library/Zend/Form/View/Helper/FormRow.php
  • Loading branch information...
commit 90e4176852197c49eef3cd47ac0af2440ffc3f29 2 parents 08d264c + 0865d2b
@weierophinney weierophinney authored
View
5 library/Zend/Form/View/Helper/FormRow.php
@@ -160,7 +160,9 @@ public function render(ElementInterface $element)
$elementString = $elementHelper->render($element);
- if (isset($label) && '' !== $label) {
+ // hidden elements do not need a <label> -https://github.com/zendframework/zf2/issues/5607
+ $type = $element->getAttribute('type');
+ if (isset($label) && '' !== $label && $type !== 'hidden') {
$labelAttributes = array();
@@ -178,7 +180,6 @@ public function render(ElementInterface $element)
// Multicheckbox elements have to be handled differently as the HTML standard does not allow nested
// labels. The semantic way is to group them inside a fieldset
- $type = $element->getAttribute('type');
if ($type === 'multi_checkbox'
|| $type === 'radio'
|| $element instanceof MonthSelect
View
8 tests/ZendTest/Form/View/Helper/FormRowTest.php
@@ -82,6 +82,14 @@ public function testCanCreateMarkupWithoutLabel()
$this->assertRegexp('/<input name="foo" type="text"[^\/>]*\/?>/', $markup);
}
+ public function testIgnoreLabelForHidden()
+ {
+ $element = new Element\Hidden('foo');
+ $element->setLabel('My label');
+ $markup = $this->helper->render($element);
+ $this->assertEquals('<input type="hidden" name="foo" value=""/>', $markup);
+ }
+
public function testCanHandleMultiCheckboxesCorrectly()
{
$options = array(
Please sign in to comment.
Something went wrong with that request. Please try again.