From 0ec598adf7fae6e755b49d1d6207ccc2e69ceff7 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Mon, 15 Sep 2025 16:11:54 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B06071=20-=20Prefill=20Tagset=20in=20trans?= =?UTF-8?q?ition=20displayed=20but=20not=20saved?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/cmdbabstract.class.inc.php | 27 +++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index db70affe93..6b56b279ff 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -4263,9 +4263,30 @@ protected function PrepareValueFromPostedForm($sFormPrefix, $sAttCode, $sClass = case 'Set': case 'TagSet': $sTagSetJson = utils::ReadPostedParam("attr_{$sFormPrefix}{$sAttCode}", null, 'raw_data'); - if ($sTagSetJson !== null) { // bulk modify, direct linked set not handled - $value = json_decode($sTagSetJson, true); - } + if ($sTagSetJson !== null) { // bulk modify, direct linked set not handled + $value = json_decode($sTagSetJson, true); + if ($this->IsNew()) { + if ($value['orig_value'] != '' ) { + foreach ($value['orig_value'] as $val) { + if (!in_array($val, $value['removed'])) { + $value['added'][] = $val; + } + } + } + } else { + $acurrentValues = $this->Get($sAttCode)->GetValues(); + foreach ($value['orig_value'] as $val) { + if ( !in_array($val, $acurrentValues) && !in_array($val, $value['removed']) && !in_array($val, $value['added']) ) { + $value['added'][] = $val; + } + } + foreach ($acurrentValues as $val) { + if ( !in_array($val, $value['orig_value']) && !in_array($val, $value['removed']) && !in_array($val, $value['added']) ) { + $value['removed'][] = $val; + } + } + } + } break; default: