Skip to content
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #143 from seyfer/master
Browse files Browse the repository at this point in the history
Fix issue #139
  • Loading branch information
neilime committed May 14, 2015
2 parents 5f4521a + 07549da commit 234cede
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
/nbproject/
nbactions.xml
nb-configuration.xml
/build/
/build/
.idea/
17 changes: 11 additions & 6 deletions src/TwbBundle/Form/View/Helper/TwbBundleFormButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ public function render(ElementInterface $oElement, $sButtonContent = null)
* Define button content
*/
if (null === $sButtonContent) {
$sButtonContent = $oElement->getLabel();
$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, ' .
Expand Down Expand Up @@ -119,24 +124,24 @@ 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'];
}

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',
Expand Down Expand Up @@ -200,7 +205,7 @@ public function render(ElementInterface $oElement, $sButtonContent = null)
$sMarkup = $this->openTag($oElement) .
sprintf(self::$dropdownToggleFormat, $sButtonContent) .
$this->closeTag();
} else {
} else {
/*
* Add caret element
*/
Expand Down

0 comments on commit 234cede

Please sign in to comment.