Browse Source

Pass all the button's config array to Button::widget() instead of creating new one item by item. Now allowed to pass in ButtonGroup button's configs any possible attributes(like tagName, encodeLabel, etc).

tags/2.0.1
fly 10 years ago committed by Qiang Xue
parent
commit
2888d98221
  1. 13
      ButtonGroup.php

13
ButtonGroup.php

@ -7,7 +7,6 @@
namespace yii\bootstrap; namespace yii\bootstrap;
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
/** /**
@ -81,14 +80,10 @@ class ButtonGroup extends Widget
$buttons = []; $buttons = [];
foreach ($this->buttons as $button) { foreach ($this->buttons as $button) {
if (is_array($button)) { if (is_array($button)) {
$label = ArrayHelper::getValue($button, 'label'); $button['view'] = $this->getView();
$options = ArrayHelper::getValue($button, 'options'); if (!isset($button['encodeLabel']))
$buttons[] = Button::widget([ $button['encodeLabel'] = $this->encodeLabels;
'label' => $label, $buttons[] = Button::widget($button);
'options' => $options,
'encodeLabel' => $this->encodeLabels,
'view' => $this->getView()
]);
} else { } else {
$buttons[] = $button; $buttons[] = $button;
} }

Loading…
Cancel
Save