FIX 11.0 - when a mandatory extrafield of type sellist contains '0' it should be considered empty and trigger an error message upon insertion

This commit is contained in:
Florian Mortgat 2021-01-27 23:46:09 +01:00
parent e431b5aacb
commit 8dfe39258b
2 changed files with 5 additions and 1 deletions

View File

@ -5238,6 +5238,7 @@ abstract class CommonObject
$mandatorypb = false;
if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb = true;
if ($this->array_options[$key] === '') $mandatorypb = true;
if ($attributeType == 'sellist' && $this->array_options[$key] == '0') $mandatorypb = true;
if ($mandatorypb)
{
dol_syslog("Mandatory extra field ".$key." is empty");

View File

@ -2060,9 +2060,12 @@ class ExtraFields
if ($this->attributes[$object->table_element]['required'][$key]) // Value is required
{
// Check if empty without using GETPOST, value can be alpha, int, array, etc...
// check if functionally empty without using GETPOST (depending on the type of extrafield, a
// technically non-empty value may be treated as empty functionally).
// value can be alpha, int, array, etc...
if ((!is_array($_POST["options_".$key]) && empty($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] != 'select' && $_POST["options_".$key] != '0')
|| (!is_array($_POST["options_".$key]) && empty($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] == 'select')
|| (!is_array($_POST["options_".$key]) && isset($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] == 'sellist' && $_POST['options_' . $key] == '0')
|| (is_array($_POST["options_".$key]) && empty($_POST["options_".$key])))
{
//print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key];