From 3e262170deb30405ae0a5be8371a5f17d73ba733 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 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 08354b1878..1e451cfd88 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -4155,6 +4155,27 @@ protected function PrepareValueFromPostedForm($sFormPrefix, $sAttCode, $sClass = $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 ($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;