From 0c7b7ed7f46b8fa2d1954ec733dbf44802d8f3d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Oct 2018 14:26:18 +0200 Subject: [PATCH] FIX Required extrafield value numeric should accept '0' --- htdocs/core/class/extrafields.class.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 200c869f5e8..ae859181f67 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1847,11 +1847,16 @@ class ExtraFields if (empty($enabled)) continue; if (empty($perms)) continue; - if ($this->attributes[$object->table_element]['required'][$key] && empty($_POST["options_".$key])) // Check if empty without GETPOST, value can be alpha, int, array, etc... + if ($this->attributes[$object->table_element]['required'][$key]) // Value is required { - //print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key]; - $nofillrequired++; - $error_field_required[] = $langs->transnoentitiesnoconv($value); + // Check if empty without using GETPOST, value can be alpha, int, array, etc... + if ((! is_array($_POST["options_".$key]) && empty($_POST["options_".$key]) && $_POST["options_".$key] != '0') + || (is_array($_POST["options_".$key]) && empty($_POST["options_".$key]))) + { + //print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key]; + $nofillrequired++; + $error_field_required[] = $langs->transnoentitiesnoconv($value); + } } if (in_array($key_type,array('date')))