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