From f651e72372fdca6b0a0eca3767fe5fb1865b68f0 Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Wed, 29 May 2013 14:13:19 +0200 Subject: [PATCH] refactored label render --- framework/yii/bootstrap/Button.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/framework/yii/bootstrap/Button.php b/framework/yii/bootstrap/Button.php index bdc29ca..94cdae8 100644 --- a/framework/yii/bootstrap/Button.php +++ b/framework/yii/bootstrap/Button.php @@ -64,6 +64,10 @@ class Button extends Widget */ public $label; /** + * @var array the HTML attributes of the button. + */ + public $buttonOptions = array(); + /** * @var array list of menu items in the dropdown. Each array element represents a single * menu with the following structure: * @@ -120,16 +124,23 @@ class Button extends Widget protected function renderLabel() { $label = $this->encodeLabels ? Html::encode($this->label) : $this->label; - $options = array('class' => 'btn dropdown-toggle', 'data-toggle' => 'dropdown'); + $this->addCssClass($this->buttonOptions, 'btn'); + $splitButton = ''; if ($this->split) { $tag = 'button'; - $label .= Html::tag('button', '', $options); - $options = array('class' => 'btn'); + $options = $this->buttonOptions; + $this->buttonOptions['data-toggle'] = 'dropdown'; + $this->addCssClass($this->buttonOptions, 'dropdown-toggle'); + $splitButton = Html::tag('button', '', $this->buttonOptions); } else { $tag = 'a'; - $options['href'] = '#'; + $options = $this->buttonOptions; + if (!isset($options['href'])) { + $options['href'] = '#'; + } + $options['data-toggle'] = 'dropdown'; } - return Html::tag($tag, $label, $options); + return Html::tag($tag, $label, $options) . "\n" . $splitButton; } /**