From 694baf3110174e595a5faff9f465d2899429f3c1 Mon Sep 17 00:00:00 2001 From: Thomas Schulze Date: Wed, 1 Sep 2021 22:36:39 +0200 Subject: [PATCH] fix multiple buttons with same configurations --- CHANGELOG.md | 8 +++++--- src/fields/Buttons.php | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31fb851..d462133 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ # Customizable Radio Buttons Field Changelog -## Unreleased -### Changed -- Fixed background color of icon +## 1.0.2 - 2021-09-01 +### Fixed +- Add wrap and gap to the buttons (thanks to @emsuiko). +- Fixed background color of icon. +- Fixed a bug when two or more same configurations were used in one tab/ matrix block. ## 1.0.1 - 2019-09-15 ### Fixed diff --git a/src/fields/Buttons.php b/src/fields/Buttons.php index 5e190b3..5c369df 100644 --- a/src/fields/Buttons.php +++ b/src/fields/Buttons.php @@ -84,9 +84,10 @@ public function getInputHtml($value, ElementInterface $element = null): string $buttons = []; foreach ($group['buttons'] as $handle => $button) { - $buttons[$handle] = array_merge($this->defaultButton, $button); - if ($buttons[$handle]['image'] !== '') { - $buttons[$handle]['image'] = Craft::$app->assetManager->getPublishedUrl($buttons[$handle]['image'], true); + $fieldHandle = $this->handle . '-' . $handle; + $buttons[$fieldHandle] = array_merge($this->defaultButton, $button); + if ($buttons[$fieldHandle]['image'] !== '') { + $buttons[$fieldHandle]['image'] = Craft::$app->assetManager->getPublishedUrl($buttons[$fieldHandle]['image'], true); } }