diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 90b350b3f32..7ae0bffd0ca 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6385,6 +6385,16 @@ abstract class CommonObject } } } + } else { + /** + We are in a situation where the current object has no values in its extra fields. + We want to initialize all the values to null so that the array_option is accessible in other contexts (especially in document generation). + **/ + if (is_array($extrafields->attributes[$this->table_element]['label'])) { + foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { + $this->array_options['options_' . $key] = null; + } + } } // If field is a computed field, value must become result of compute (regardless of whether a row exists