FIX: commonobject: don't require notnull field if default set
This commit is contained in:
parent
1dc466e1fb
commit
893ce55852
@ -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');
|
||||
|
||||
@ -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']);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user