diff --git a/ButtonDropdown.php b/ButtonDropdown.php
index 3f2a236..310b4a0 100644
--- a/ButtonDropdown.php
+++ b/ButtonDropdown.php
@@ -8,6 +8,7 @@
namespace yii\bootstrap;
use yii\helpers\ArrayHelper;
+use yii\helpers\Url;
/**
* ButtonDropdown renders a group or split button dropdown bootstrap component.
@@ -104,11 +105,12 @@ class ButtonDropdown extends Widget
if ($this->encodeLabel) {
$label = Html::encode($label);
}
+
if ($this->split) {
$options = $this->options;
$this->options['data-toggle'] = 'dropdown';
Html::addCssClass($this->options, ['toggle' => 'dropdown-toggle']);
- unset($this->options['id']);
+ unset($options['id']);
$splitButton = Button::widget([
'label' => '',
'encodeLabel' => false,
@@ -118,14 +120,21 @@ class ButtonDropdown extends Widget
} else {
$label .= ' ';
$options = $this->options;
- if (!isset($options['href']) && $this->tagName === 'a') {
- $options['href'] = '#';
- }
Html::addCssClass($options, ['toggle' => 'dropdown-toggle']);
$options['data-toggle'] = 'dropdown';
$splitButton = '';
}
+ if (isset($options['href'])) {
+ if (is_array($options['href'])) {
+ $options['href'] = Url::to($options['href']);
+ }
+ } else {
+ if ($this->tagName === 'a') {
+ $options['href'] = '#';
+ }
+ }
+
return Button::widget([
'tagName' => $this->tagName,
'label' => $label,
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9324d4c..28013cc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@ Yii Framework 2 bootstrap extension Change Log
2.0.8 under development
-----------------------
+- Bug #126: Fixed `yii\bootstrap\ToggleButtonGroup` toggles dropdown for both buttons in case `split` is enabled (klimov-paul)
- Enh #219: Add ability to use custom HTML in navbar-header (razvanphp)
- Enh #171: Add ability to use a brandImage with the navbar (razvanphp)