diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php index e225f1f..76cebe8 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php @@ -123,7 +123,7 @@ protected function renderElement(\Zend\Form\ElementInterface $oElement) $sLayout = $oElement->getOption('twb-layout'); //Render label - $sLabelOpen = $sLabelClose = $sLabelContent = ''; + $sLabelOpen = $sLabelClose = $sLabelContent = $sElementType = ''; if ($sLabelContent = $this->renderLabel($oElement)) { //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 $sElementType = $oElement->getAttribute('type'); @@ -210,6 +210,16 @@ protected function renderElement(\Zend\Form\ElementInterface $oElement) $sClass .= ' col-' . $sColumSize; } + // Checkbox elements are a special case. They don't need to render a label again + if ($sElementType === 'checkbox') { + return sprintf( + self::$horizontalLayoutFormat, + '', + $sClass, + $sElementContent + ); + } + return sprintf( self::$horizontalLayoutFormat, $sLabelOpen . $sLabelContent . $sLabelClose, diff --git a/tests/_files/expected-forms/control-states-form-horizontal.phtml b/tests/_files/expected-forms/control-states-form-horizontal.phtml index d91fdaf..3f00254 100644 --- a/tests/_files/expected-forms/control-states-form-horizontal.phtml +++ b/tests/_files/expected-forms/control-states-form-horizontal.phtml @@ -1,6 +1,6 @@
\ No newline at end of file diff --git a/tests/_files/expected-forms/horizontal-form.phtml b/tests/_files/expected-forms/horizontal-form.phtml index cf62152..c8e2df9 100644 --- a/tests/_files/expected-forms/horizontal-form.phtml +++ b/tests/_files/expected-forms/horizontal-form.phtml @@ -1,5 +1,5 @@ \ No newline at end of file