Commit 59f6b7fc by Qiang Xue

Merge pull request #1601 from omnilight/improving-buttondropdown

Added support for tagName and encodeLabel parameters in ButtonDropdown
parents c04e6507 6b95b2ad
...@@ -49,6 +49,14 @@ class ButtonDropdown extends Widget ...@@ -49,6 +49,14 @@ class ButtonDropdown extends Widget
* @var boolean whether to display a group of split-styled button group. * @var boolean whether to display a group of split-styled button group.
*/ */
public $split = false; public $split = false;
/**
* @var string the tag to use to render the button
*/
public $tagName = 'button';
/**
* @var boolean whether the label should be HTML-encoded.
*/
public $encodeLabel = true;
/** /**
...@@ -68,7 +76,6 @@ class ButtonDropdown extends Widget ...@@ -68,7 +76,6 @@ class ButtonDropdown extends Widget
{ {
Html::addCssClass($this->options, 'btn'); Html::addCssClass($this->options, 'btn');
if ($this->split) { if ($this->split) {
$tag = 'button';
$options = $this->options; $options = $this->options;
$this->options['data-toggle'] = 'dropdown'; $this->options['data-toggle'] = 'dropdown';
Html::addCssClass($this->options, 'dropdown-toggle'); Html::addCssClass($this->options, 'dropdown-toggle');
...@@ -78,7 +85,6 @@ class ButtonDropdown extends Widget ...@@ -78,7 +85,6 @@ class ButtonDropdown extends Widget
'options' => $this->options, 'options' => $this->options,
]); ]);
} else { } else {
$tag = 'a';
$this->label .= ' <span class="caret"></span>'; $this->label .= ' <span class="caret"></span>';
$options = $this->options; $options = $this->options;
if (!isset($options['href'])) { if (!isset($options['href'])) {
...@@ -89,10 +95,10 @@ class ButtonDropdown extends Widget ...@@ -89,10 +95,10 @@ class ButtonDropdown extends Widget
$splitButton = ''; $splitButton = '';
} }
return Button::widget([ return Button::widget([
'tagName' => $tag, 'tagName' => $this->tagName,
'label' => $this->label, 'label' => $this->label,
'options' => $options, 'options' => $options,
'encodeLabel' => false, 'encodeLabel' => $this->encodeLabel,
]) . "\n" . $splitButton; ]) . "\n" . $splitButton;
} }
......
...@@ -7,6 +7,7 @@ Yii Framework 2 bootstrap extension Change Log ...@@ -7,6 +7,7 @@ Yii Framework 2 bootstrap extension Change Log
- Enh #1474: Added option to make NavBar 100% width (cebe) - Enh #1474: Added option to make NavBar 100% width (cebe)
- Enh #1553: Only add navbar-default class to NavBar when no other class is specified (cebe) - Enh #1553: Only add navbar-default class to NavBar when no other class is specified (cebe)
- Bug #1459: Update Collapse to use bootstrap 3 classes (tonydspaniard) - Bug #1459: Update Collapse to use bootstrap 3 classes (tonydspaniard)
- Enh: Added support for tagName and encodeLabel parameters in ButtonDropdown (omnilight)
2.0.0 alpha, December 1, 2013 2.0.0 alpha, December 1, 2013
----------------------------- -----------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment