From 233b3762b0324a16eb4d6d06e0ff11965c65b926 Mon Sep 17 00:00:00 2001 From: seyfer Date: Sat, 25 Apr 2015 13:54:54 +0700 Subject: [PATCH 1/2] Fix issue #139 --- .gitignore | 3 ++- .../Form/View/Helper/TwbBundleFormButton.php | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 5c850d6..073c844 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ /nbproject/ nbactions.xml nb-configuration.xml -/build/ \ No newline at end of file +/build/ +.idea/ diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormButton.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormButton.php index 2cba5a5..571c62f 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormButton.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormButton.php @@ -87,7 +87,7 @@ public function render(ElementInterface $oElement, $sButtonContent = null) * Define button content */ if (null === $sButtonContent) { - $sButtonContent = $oElement->getLabel(); + $sButtonContent = $oElement->getValue(); if (null === $sButtonContent && !$aIconOptions) { throw new DomainException(sprintf( '%s expects either button content as the second argument, ' . @@ -119,16 +119,16 @@ public function render(ElementInterface $oElement, $sButtonContent = null) 'position' => self::ICON_PREPEND ); } - + if (!is_array($aIconOptions)) { throw new LogicException(sprintf( '"glyphicon" and "fontAwesome" button option expects a scalar value or an array, "%s" given', is_object($aIconOptions) ? get_class($aIconOptions) : gettype($aIconOptions) )); } - + $position = 'prepend'; - + if (!empty($aIconOptions['position'])) { $position = $aIconOptions['position']; } @@ -136,7 +136,7 @@ public function render(ElementInterface $oElement, $sButtonContent = null) if (!empty($aIconOptions['icon'])) { $icon = $aIconOptions['icon']; } - + if (!is_scalar($icon)) { throw new LogicException(sprintf( 'Glyphicon and fontAwesome "icon" option expects a scalar value, "%s" given', @@ -200,7 +200,7 @@ public function render(ElementInterface $oElement, $sButtonContent = null) $sMarkup = $this->openTag($oElement) . sprintf(self::$dropdownToggleFormat, $sButtonContent) . $this->closeTag(); - } else { + } else { /* * Add caret element */ From 07549dacab8c83f15ef138183d32d57a5cd074a3 Mon Sep 17 00:00:00 2001 From: seyfer Date: Thu, 14 May 2015 18:47:39 +0700 Subject: [PATCH 2/2] compability --- src/TwbBundle/Form/View/Helper/TwbBundleFormButton.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormButton.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormButton.php index 571c62f..6cfc04b 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormButton.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormButton.php @@ -88,6 +88,11 @@ public function render(ElementInterface $oElement, $sButtonContent = null) */ if (null === $sButtonContent) { $sButtonContent = $oElement->getValue(); + + if (!$sButtonContent) { + $sButtonContent = $oElement->getLabel(); + } + if (null === $sButtonContent && !$aIconOptions) { throw new DomainException(sprintf( '%s expects either button content as the second argument, ' .