From 18775c06ea9bed16c8590f9b0590a96c7cd0e531 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Sat, 30 Nov 2024 13:06:36 +0100 Subject: [PATCH] FIX #31890 store empty line extrafields (#32152) * FIX #31890 store empty line extrafields If a line extrafield had originally some contents, after deleting it and submitting it as empty, the extrafield was not stored but the original contents kept * corrected whitespace --- htdocs/core/class/extrafields.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index d58bcdc574341..a1b1151a15d3d 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -11,6 +11,7 @@ * Copyright (C) 2017 Nicolas ZABOURI * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2022 Antonin MARCHAL + * Copyright (C) 2024 Joachim Kueter * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2415,10 +2416,13 @@ public function getOptionalsFromPost($extrafieldsobjectkey, $keyprefix = '', $ke } $value_key = dol_htmlcleanlastbr(GETPOST($keysuffix."options_".$key.$keyprefix, 'restricthtml')); } else { - if (!GETPOST($keysuffix."options_".$key.$keyprefix)) { + if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) { continue; // Value was not provided, we should not set it. } $value_key = GETPOST($keysuffix."options_".$key.$keyprefix); + if ($value_key === '') { + $value_key = null; + } } $array_options[$keysuffix."options_".$key] = $value_key; // No keyprefix here. keyprefix is used only for read.