diff --git a/ButtonDropdown.php b/ButtonDropdown.php index 5993217..cb6fbb0 100644 --- a/ButtonDropdown.php +++ b/ButtonDropdown.php @@ -67,6 +67,11 @@ class ButtonDropdown extends Widget * @var boolean whether the label should be HTML-encoded. */ public $encodeLabel = true; + /** + * @var string name of a class to use for rendering dropdowns withing this widget. Defaults to [[Dropdown]]. + * @since 2.0.7 + */ + public $dropdownClass = 'yii\bootstrap\Dropdown'; /** @@ -139,7 +144,8 @@ class ButtonDropdown extends Widget $config = $this->dropdown; $config['clientOptions'] = false; $config['view'] = $this->getView(); - - return Dropdown::widget($config); + /** @var Widget $dropdownClass */ + $dropdownClass = $this->dropdownClass; + return $dropdownClass::widget($config); } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 829d237..4919689 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 bootstrap extension Change Log 2.0.7 under development ----------------------- +- Enh #145: Added the ability to customize the class used to draw dropdowns in `yii\bootstrap\Nav`, `yii\bootstrapButtonDropdown` and `yii\bootstrap\Tab` widgets (PowerGamer1) - Bug #126: `yii\bootstrap\ToggleButtonGroup` was unable to work without model (makroxyz) - Bug #130: Fixed `yii\bootstrap\Collapse` to use pure numerical value on `content` property (meysampg) - Bug #137: Remove `role="navbar"` from `yii\bootstrap\NavBar` according to new aria specification (tino415) diff --git a/Nav.php b/Nav.php index bf755e4..3598b9d 100644 --- a/Nav.php +++ b/Nav.php @@ -105,6 +105,11 @@ class Nav extends Widget * Defaults to `null` which means `` will be used. To disable the caret, set this property to be an empty string. */ public $dropDownCaret; + /** + * @var string name of a class to use for rendering dropdowns withing this widget. Defaults to [[Dropdown]]. + * @since 2.0.7 + */ + public $dropdownClass = 'yii\bootstrap\Dropdown'; /** @@ -211,7 +216,9 @@ class Nav extends Widget */ protected function renderDropdown($items, $parentItem) { - return Dropdown::widget([ + /** @var Widget $dropdownClass */ + $dropdownClass = $this->dropdownClass; + return $dropdownClass::widget([ 'options' => ArrayHelper::getValue($parentItem, 'dropDownOptions', []), 'items' => $items, 'encodeLabels' => $this->encodeLabels, diff --git a/Tabs.php b/Tabs.php index 8872981..3173040 100644 --- a/Tabs.php +++ b/Tabs.php @@ -118,6 +118,11 @@ class Tabs extends Widget * @since 2.0.1 */ public $renderTabContent = true; + /** + * @var string name of a class to use for rendering dropdowns withing this widget. Defaults to [[Dropdown]]. + * @since 2.0.7 + */ + public $dropdownClass = 'yii\bootstrap\Dropdown'; /** @@ -176,8 +181,10 @@ class Tabs extends Widget if (!isset($linkOptions['data-toggle'])) { $linkOptions['data-toggle'] = 'dropdown'; } + /** @var Widget $dropdownClass */ + $dropdownClass = $this->dropdownClass; $header = Html::a($label, "#", $linkOptions) . "\n" - . Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]); + . $dropdownClass::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]); } else { $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n);