From ed42211cf1fac0e25a8a30c548e56262636252fb Mon Sep 17 00:00:00 2001 From: Alexander Zamponi Date: Sun, 29 Jan 2017 18:24:01 +0100 Subject: [PATCH] Fixed the showLabel location and changed the readme --- src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php | 4 ++-- .../TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php index 5a93ac8..a57b5fb 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php @@ -217,9 +217,9 @@ protected function renderElement(ElementInterface $oElement, $sLabelPosition = n case TwbBundleForm::LAYOUT_INLINE: if ($sElementType !== 'checkbox') { if ($sElementType !== 'checkbox') { - if (empty($aLabelAttributes['class']) && empty($aLabelAttributes['showLabel']) ) { + if (empty($aLabelAttributes['class']) && empty($oElement->getOption('showLabel'))) { $aLabelAttributes['class'] = 'sr-only'; - } elseif (empty($aLabelAttributes['showLabel']) && !preg_match('/(\s|^)sr-only(\s|$)/', $aLabelAttributes['class'])) { + } elseif (empty($oElement->getOption('showLabel')) && !preg_match('/(\s|^)sr-only(\s|$)/', $aLabelAttributes['class'])) { $aLabelAttributes['class'] = trim($aLabelAttributes['class'] . ' sr-only'); } } diff --git a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php index 8629572..9dd6cf5 100644 --- a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php +++ b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php @@ -90,7 +90,7 @@ public function testInlineForm() 'placeholder' => 'Enter email', 'id' => 'exampleInputEmail2' ), - 'options' => array('label' => 'Email address', 'label_attributes' => [ 'showLabel' => false ],) + 'options' => array('label' => 'Email address', 'showLabel' => false) ))->add(array( 'name' => 'input-email2', 'attributes' => array( @@ -98,7 +98,7 @@ public function testInlineForm() 'placeholder' => 'Enter email2', 'id' => 'exampleInputEmail2a' ), - 'options' => array('label' => 'Email address2', 'label_attributes' => [ 'showLabel' => true ],) + 'options' => array('label' => 'Email address2', 'showLabel' => true) ))->add(array( 'name' => 'input-password', 'attributes' => array(