From 98ffdfd1c4a4db7b2ee8c63601cf4ddfbe9a7ebc Mon Sep 17 00:00:00 2001 From: Matt Sidnell <54064522+pstructures@users.noreply.github.com> Date: Wed, 15 Apr 2020 12:53:39 +0100 Subject: [PATCH] Added Boolean Support Added support to convert Boolean from 'on' to 1 in order for compatibility with the common object. --- htdocs/core/actions_addupdatedelete.inc.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 077c577ff26..66ed09413ef 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -75,6 +75,8 @@ if ($action == 'add' && !empty($permissiontoadd)) $value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int'); } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) { $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup + } elseif ($object->fields[$key]['type'] == 'boolean') { + $value = (GETPOST($key) == 'on' ? 1 : 0); } else { $value = GETPOST($key, 'alphanohtml'); } @@ -156,6 +158,8 @@ if ($action == 'update' && !empty($permissiontoadd)) } } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) { $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup + } elseif ($object->fields[$key]['type'] == 'boolean') { + $value = (GETPOST($key) == 'on' ? 1 : 0); } else { $value = GETPOST($key, 'alpha'); }