FIX: commonobject: don't require notnull field if default set

This commit is contained in:
Marc de Lima Lucio 2018-04-19 10:29:48 +02:00
parent 1dc466e1fb
commit 893ce55852
2 changed files with 3 additions and 3 deletions

View File

@ -62,7 +62,7 @@ if ($action == 'add' && ! empty($permissiontoadd))
if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field
$object->$key=$value;
if ($val['notnull'] > 0 && $object->$key == '')
if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default']))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors');
@ -117,7 +117,7 @@ if ($action == 'update' && ! empty($permissiontoadd))
if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field
$object->$key=$value;
if ($val['notnull'] > 0 && $object->$key == '')
if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default']))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors');

View File

@ -6278,7 +6278,7 @@ abstract class CommonObject
if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]='';
//var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1));
if ($this->fields[$key]['notnull'] == 1 && ! isset($values[$key]))
if ($this->fields[$key]['notnull'] == 1 && ! isset($values[$key]) && is_null($val['default']))
{
$error++;
$this->errors[]=$langs->trans("ErrorFieldRequired", $this->fields[$key]['label']);