From 821ed27b2cc824f828968df89d5eedd1cfa20610 Mon Sep 17 00:00:00 2001 From: b1ek Date: Tue, 20 Aug 2024 17:42:50 +1000 Subject: [PATCH] fix: undefined behaviour in ParameterForm edit --- models/ParameterForm.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/models/ParameterForm.php b/models/ParameterForm.php index 683e8a9..84dc013 100644 --- a/models/ParameterForm.php +++ b/models/ParameterForm.php @@ -55,11 +55,22 @@ class ParameterForm extends Model if ($param->type == 2) { if ($this->icon) { $icon = Image::fromUploadedFile($this->icon); - $param->icon = $icon->id; + + // https://rent4health.com/wp-content/uploads/2020/02/Under-arm-crutches-1.png + if ($param->getAttribute('icon') !== null) { + $param->icon = $icon->id; + } else { + $param->setAttribute('icon', $icon->id); + } } if ($this->iconGray) { $iconGray = Image::fromUploadedFile($this->iconGray); - $param->iconGray = $iconGray->id; + + if ($param->getAttribute('icon_gray') !== null) { + $param->iconGray = $iconGray->id; + } else { + $param->setAttribute('icon_gray', $iconGray->id); + } } $param->setAttributes([