From 23b44e609ba8a6d46a49518f448a67145fcce02f Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 26 Nov 2014 23:41:36 +0300 Subject: [PATCH] Fixes #4146: Added `yii\bootstrap\ButtonDropdown::$containerOptions` --- ButtonDropdown.php | 18 ++++++++++++++++-- CHANGELOG.md | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ButtonDropdown.php b/ButtonDropdown.php index 5fc6f62..3563d71 100644 --- a/ButtonDropdown.php +++ b/ButtonDropdown.php @@ -7,6 +7,7 @@ namespace yii\bootstrap; +use yii\helpers\ArrayHelper; use yii\helpers\Html; /** @@ -38,6 +39,15 @@ class ButtonDropdown extends Widget */ public $label = 'Button'; /** + * @var array the HTML attributes for the container tag. The following special options are recognized: + * + * - tag: string, defaults to "div", the name of the container tag. + * + * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. + * @since 2.0.1 + */ + public $containerOptions = []; + /** * @var array the HTML attributes of the button. * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. */ @@ -65,10 +75,14 @@ class ButtonDropdown extends Widget */ public function run() { - echo Html::beginTag('div', ['class' => 'btn-group']); + Html::addCssClass($this->containerOptions, 'btn-group'); + $options = $this->containerOptions; + $tag = ArrayHelper::remove($options, 'tag', 'div'); + + echo Html::beginTag($tag, $this->containerOptions); echo "\n" . $this->renderButton(); echo "\n" . $this->renderDropdown(); - echo "\n" . Html::endTag('div'); + echo "\n" . Html::endTag($tag); $this->registerPlugin('button'); } diff --git a/CHANGELOG.md b/CHANGELOG.md index a7f48cc..b821620 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,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 #4146: Added `yii\bootstrap\ButtonDropdown::$containerOptions` (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)