Commit d36bf9e8 by fly Committed by Qiang Xue

Pass all the button's config array to Button::widget() instead of creating new…

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).
parent 4e47b67f
...@@ -7,7 +7,6 @@ ...@@ -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 ...@@ -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;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment