Merge pull request #14656 from OPEN-DSI/v10-fix-extrafields-select-required

FIX no empty value in required extrafield
This commit is contained in:
Laurent Destailleur 2020-10-23 17:29:12 +02:00 committed by GitHub
commit 377c44eeab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1147,7 +1147,7 @@ class ExtraFields
} }
$out.='<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>'; $out.='<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
$out.='<option value="0">&nbsp;</option>'; $out .= '<option value="0">&nbsp;</option>';
foreach ($param['options'] as $key => $val) foreach ($param['options'] as $key => $val)
{ {
if ((string) $key == '') continue; if ((string) $key == '') continue;
@ -2008,8 +2008,8 @@ class ExtraFields
if ($this->attributes[$object->table_element]['required'][$key]) // Value is required 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 empty without using GETPOST, 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') if ((! is_array($_POST["options_".$key]) && empty($_POST["options_".$key]) && !in_array($this->attributes[$object->table_element]['type'][$key], array('select', 'sellist')) && $_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]) && empty($_POST["options_".$key]) && in_array($this->attributes[$object->table_element]['type'][$key], array('select', 'sellist')))
|| (is_array($_POST["options_".$key]) && empty($_POST["options_".$key]))) || (is_array($_POST["options_".$key]) && empty($_POST["options_".$key])))
{ {
//print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key]; //print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key];