Browse Source

Fixes #4146: Added `yii\bootstrap\ButtonDropdown::$containerOptions`

tags/2.0.1
Alexander Makarov 10 years ago
parent
commit
23b44e609b
  1. 18
      ButtonDropdown.php
  2. 1
      CHANGELOG.md

18
ButtonDropdown.php

@ -7,6 +7,7 @@
namespace yii\bootstrap; namespace yii\bootstrap;
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
/** /**
@ -38,6 +39,15 @@ class ButtonDropdown extends Widget
*/ */
public $label = 'Button'; 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. * @var array the HTML attributes of the button.
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/ */
@ -65,10 +75,14 @@ class ButtonDropdown extends Widget
*/ */
public function run() 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->renderButton();
echo "\n" . $this->renderDropdown(); echo "\n" . $this->renderDropdown();
echo "\n" . Html::endTag('div'); echo "\n" . Html::endTag($tag);
$this->registerPlugin('button'); $this->registerPlugin('button');
} }

1
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 #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) - 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 #4181: Added `yii\bootstrap\Modal::$headerOptions` and `yii\bootstrap\Modal::$footerOptions` (tuxoff, samdark)
- Enh #4450: Added `yii\bootstrap\Nav::renderDropdown()` (qiangxue) - Enh #4450: Added `yii\bootstrap\Nav::renderDropdown()` (qiangxue)
- Enh #5735: Added `yii\bootstrap\Tabs::renderTabContent` to support manually rendering tab contents (RomeroMsk) - Enh #5735: Added `yii\bootstrap\Tabs::renderTabContent` to support manually rendering tab contents (RomeroMsk)

Loading…
Cancel
Save