diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b82970baa97..5c0139aeb8e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9738,14 +9738,16 @@ abstract class CommonObject } // Force values to default values when known - foreach ($this->fields as $key => $value) { - // If fields are already set, do nothing - if (array_key_exists($key, $fields)) { - continue; - } + if (property_exists($this, 'fields')) { + foreach ($this->fields as $key => $value) { + // If fields are already set, do nothing + if (array_key_exists($key, $fields)) { + continue; + } - if (!empty($value['default'])) { - $this->$key = $value['default']; + if (!empty($value['default'])) { + $this->$key = $value['default']; + } } }