From 1576cade5c65bcde620fcce5b8d6a4d62a0d9f10 Mon Sep 17 00:00:00 2001 From: Alfredo Costa Date: Tue, 17 Oct 2017 14:41:28 -0200 Subject: [PATCH] Ability to set the btn-group class Instead of `'btn-group' => true,` We'll use `'btn-group' => [ 'btn-class' => 'btn btn-success', ],` --- src/TwbBundle/Form/View/Helper/TwbBundleFormRadio.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormRadio.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormRadio.php index 031fae2..349039c 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormRadio.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormRadio.php @@ -46,9 +46,15 @@ public function render(ElementInterface $oElement) return $sReturn; } - if (isset($aElementOptions['btn-group']) && $aElementOptions['btn-group'] == true) { + if (isset($aElementOptions['btn-group']) && $aElementOptions['btn-group'] != false) { + + $buttonClass = 'btn btn-primary'; + if (is_array($aElementOptions['btn-group']) && isset($aElementOptions['btn-group']['btn-class'])) { + $buttonClass = $aElementOptions['btn-group']['btn-class']; + } + $this->setSeparator(''); - $oElement->setLabelAttributes(array('class' => 'btn btn-primary')); + $oElement->setLabelAttributes(array('class' => $buttonClass)); return sprintf('
%s
', parent::render($oElement)); }