From 477cce718b6a5f017b989d8a607a5e0bf7b4257a Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Fri, 28 Feb 2020 15:29:12 +0100 Subject: [PATCH 1/3] checkbox not updated when unchecked GETPOSTISSET return false in this case and the value is not updated --- htdocs/core/actions_addupdatedelete.inc.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index ebc8e48d742..754d2460fc9 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -128,6 +128,13 @@ if ($action == 'update' && !empty($permissiontoadd)) if ($object->fields[$key]['type'] == 'duration') { if (!GETPOSTISSET($key.'hour') || !GETPOSTISSET($key.'min')) continue; // The field was not submited to be edited } + elseif ($object->fields[$key]['type'] == 'boolean') { + if (!GETPOSTISSET($key)) { + $object->$key = null; + continue; // The field was not submited to be edited + } + } + else { if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited } From 50b3c760dd88ec60084ee0fa45fec8be764a442e Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Fri, 28 Feb 2020 15:47:26 +0100 Subject: [PATCH 2/3] Update actions_addupdatedelete.inc.php --- htdocs/core/actions_addupdatedelete.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 754d2460fc9..18ecc3db457 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -130,8 +130,8 @@ if ($action == 'update' && !empty($permissiontoadd)) } elseif ($object->fields[$key]['type'] == 'boolean') { if (!GETPOSTISSET($key)) { - $object->$key = null; - continue; // The field was not submited to be edited + $object->$key = 0; // use 0 instead null if the field is defined as not null + continue; } } From 89048ca52e5316eb511597aadb8d0ebba14439a8 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 28 Feb 2020 14:49:10 +0000 Subject: [PATCH 3/3] Fixing style errors. --- htdocs/core/actions_addupdatedelete.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 18ecc3db457..447c3c5e92f 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -130,8 +130,8 @@ if ($action == 'update' && !empty($permissiontoadd)) } elseif ($object->fields[$key]['type'] == 'boolean') { if (!GETPOSTISSET($key)) { - $object->$key = 0; // use 0 instead null if the field is defined as not null - continue; + $object->$key = 0; // use 0 instead null if the field is defined as not null + continue; } }