Skip to content

Commit f9fcba1

Browse files
committed
additional button options for checkbox widget.
1 parent 6f2a6c4 commit f9fcba1

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/CheckboxButtonGroup.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,22 @@ private function renderButtons()
160160
$buttons = '';
161161

162162
foreach ($this->items as $value => $label) {
163-
$buttons .= Html::button($label, [
164-
'data-value' => $value,
165-
'class' => $this->getButtonClass(
166-
$value,
167-
$this->hasModel() ? Html::getAttributeValue($this->model, $this->attribute) : $this->value
168-
),
169-
]);
163+
$buttonOptions = ArrayHelper::merge(
164+
[
165+
'data-value' => $value,
166+
'class' => $this->getButtonClass(
167+
$value,
168+
$this->hasModel()
169+
? Html::getAttributeValue($this->model, $this->attribute)
170+
: $this->value
171+
),
172+
],
173+
isset($this->itemOptions['buttons'][$value]) ? $this->itemOptions['buttons'][$value] : []
174+
);
175+
ArrayHelper::remove($buttonOptions, self::STATE_ACTIVE);
176+
ArrayHelper::remove($buttonOptions, self::STATE_DEFAULT);
177+
178+
$buttons .= Html::button($label, $buttonOptions);
170179
}
171180

172181
$class = 'btn-group checkbox-button-group';

0 commit comments

Comments
 (0)