Browse Source

Fixed `yii\bootstrap\ToggleButtonGroup` toggles dropdown for both buttons in case `split` is enabled

tags/2.0.8
Klimov Paul 7 years ago
parent
commit
3ed9dcbd3d
  1. 17
      ButtonDropdown.php
  2. 1
      CHANGELOG.md

17
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' => '<span class="caret"></span>',
'encodeLabel' => false,
@ -118,14 +120,21 @@ class ButtonDropdown extends Widget
} else {
$label .= ' <span class="caret"></span>';
$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,

1
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)

Loading…
Cancel
Save