Browse Source

ensure widget configuration are reusable

Configuration where not preserved when used multiple times.

fixes yiisoft/yii2#8231
tags/2.0.4
Carsten Brandt 10 years ago
parent
commit
37b1b59817
  1. 12
      Alert.php
  2. 2
      ButtonDropdown.php
  3. 1
      CHANGELOG.md
  4. 24
      Modal.php

12
Alert.php

@ -117,14 +117,14 @@ class Alert extends Widget
*/ */
protected function renderCloseButton() protected function renderCloseButton()
{ {
if ($this->closeButton !== false) { if (($closeButton = $this->closeButton) !== false) {
$tag = ArrayHelper::remove($this->closeButton, 'tag', 'button'); $tag = ArrayHelper::remove($closeButton, 'tag', 'button');
$label = ArrayHelper::remove($this->closeButton, 'label', '×'); $label = ArrayHelper::remove($closeButton, 'label', '×');
if ($tag === 'button' && !isset($this->closeButton['type'])) { if ($tag === 'button' && !isset($closeButton['type'])) {
$this->closeButton['type'] = 'button'; $closeButton['type'] = 'button';
} }
return Html::tag($tag, $label, $this->closeButton); return Html::tag($tag, $label, $closeButton);
} else { } else {
return null; return null;
} }

2
ButtonDropdown.php

@ -81,7 +81,7 @@ class ButtonDropdown extends Widget
$this->registerPlugin('button'); $this->registerPlugin('button');
return implode("\n", [ return implode("\n", [
Html::beginTag($tag, $this->containerOptions), Html::beginTag($tag, $options),
$this->renderButton(), $this->renderButton(),
$this->renderDropdown(), $this->renderDropdown(),
Html::endTag($tag) Html::endTag($tag)

1
CHANGELOG.md

@ -7,6 +7,7 @@ Yii Framework 2 bootstrap extension Change Log
- Bug #18: `label` option ignored by `yii\bootstrap\Activefield::checkbox()` and `yii\bootstrap\Activefield::radio()` (mikehaertl) - Bug #18: `label` option ignored by `yii\bootstrap\Activefield::checkbox()` and `yii\bootstrap\Activefield::radio()` (mikehaertl)
- Bug #5984: `yii\bootstrap\Activefield::checkbox()` caused browser to link label to the wrong input (cebe) - Bug #5984: `yii\bootstrap\Activefield::checkbox()` caused browser to link label to the wrong input (cebe)
- Bug #7894: Fixed incorrect URL config processing at `yii\bootstrap\Nav::items` if route element is not a first one (nkovacs, klimov-paul) - Bug #7894: Fixed incorrect URL config processing at `yii\bootstrap\Nav::items` if route element is not a first one (nkovacs, klimov-paul)
- Bug #8231: Configuration of Alert, ButtonDropdown, Modal widget where not preserved when used multiple times (cebe, idMolotov)
- Enh #29: Added support to list-groups for Collapse class (pana1990, skullcrasher) - Enh #29: Added support to list-groups for Collapse class (pana1990, skullcrasher)
- Enh #2546: Added `visible` option to `yii\bootstrap\ButtonGroup::$buttons` (samdark, lukBarros) - Enh #2546: Added `visible` option to `yii\bootstrap\ButtonGroup::$buttons` (samdark, lukBarros)
- Enh #7633: Added `ActionColumn::$buttonOptions` for defining HTML options to be added to the default buttons (cebe) - Enh #7633: Added `ActionColumn::$buttonOptions` for defining HTML options to be added to the default buttons (cebe)

24
Modal.php

@ -182,14 +182,14 @@ class Modal extends Widget
*/ */
protected function renderToggleButton() protected function renderToggleButton()
{ {
if ($this->toggleButton !== false) { if (($toggleButton = $this->toggleButton) !== false) {
$tag = ArrayHelper::remove($this->toggleButton, 'tag', 'button'); $tag = ArrayHelper::remove($toggleButton, 'tag', 'button');
$label = ArrayHelper::remove($this->toggleButton, 'label', 'Show'); $label = ArrayHelper::remove($toggleButton, 'label', 'Show');
if ($tag === 'button' && !isset($this->toggleButton['type'])) { if ($tag === 'button' && !isset($toggleButton['type'])) {
$this->toggleButton['type'] = 'button'; $toggleButton['type'] = 'button';
} }
return Html::tag($tag, $label, $this->toggleButton); return Html::tag($tag, $label, $toggleButton);
} else { } else {
return null; return null;
} }
@ -201,14 +201,14 @@ class Modal extends Widget
*/ */
protected function renderCloseButton() protected function renderCloseButton()
{ {
if ($this->closeButton !== false) { if (($closeButton = $this->closeButton) !== false) {
$tag = ArrayHelper::remove($this->closeButton, 'tag', 'button'); $tag = ArrayHelper::remove($closeButton, 'tag', 'button');
$label = ArrayHelper::remove($this->closeButton, 'label', '×'); $label = ArrayHelper::remove($closeButton, 'label', '×');
if ($tag === 'button' && !isset($this->closeButton['type'])) { if ($tag === 'button' && !isset($closeButton['type'])) {
$this->closeButton['type'] = 'button'; $closeButton['type'] = 'button';
} }
return Html::tag($tag, $label, $this->closeButton); return Html::tag($tag, $label, $closeButton);
} else { } else {
return null; return null;
} }

Loading…
Cancel
Save