From 4207021e7adb0d4b8d6596a9e0e91a6cfe401c09 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 26 Nov 2014 22:22:53 +0300 Subject: [PATCH] Fixes #6150: `yii\bootstrap\Tabs` dropdown IDs were generated incorrectly --- CHANGELOG.md | 1 + Tabs.php | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f481b5..a7f48cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Yii Framework 2 bootstrap extension Change Log ----------------------- - Bug #5570: `yii\bootstrap\Tabs` would throw an exception if `content` is not set for one of its `items` (RomeroMsk) +- Bug #6150: `yii\bootstrap\Tabs` dropdown IDs were generated incorrectly (samdark) - Enh #4181: Added `yii\bootstrap\Modal::$headerOptions` and `yii\bootstrap\Modal::$footerOptions` (tuxoff, samdark) - Enh #4450: Added `yii\bootstrap\Nav::renderDropdown()` (qiangxue) - Enh #5735: Added `yii\bootstrap\Tabs::renderTabContent` to support manually rendering tab contents (RomeroMsk) diff --git a/Tabs.php b/Tabs.php index 5443818..6be4374 100644 --- a/Tabs.php +++ b/Tabs.php @@ -154,7 +154,7 @@ class Tabs extends Widget $label .= ' '; Html::addCssClass($headerOptions, 'dropdown'); - if ($this->renderDropdown($item['items'], $panes)) { + if ($this->renderDropdown($n, $item['items'], $panes)) { Html::addCssClass($headerOptions, 'active'); } @@ -202,12 +202,13 @@ class Tabs extends Widget /** * Normalizes dropdown item options by removing tab specific keys `content` and `contentOptions`, and also * configure `panes` accordingly. + * @param string $itemNumber number of the item * @param array $items the dropdown items configuration. * @param array $panes the panes reference array. * @return boolean whether any of the dropdown items is `active` or not. * @throws InvalidConfigException */ - protected function renderDropdown(&$items, &$panes) + protected function renderDropdown($itemNumber, &$items, &$panes) { $itemActive = false; @@ -228,7 +229,7 @@ class Tabs extends Widget $itemActive = true; } - $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-dd-tab' . $n); + $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-dd' . $itemNumber . '-tab' . $n); $item['url'] = '#' . $options['id']; $item['linkOptions']['data-toggle'] = 'tab';