From bdfe5d0afde6dbe12d1dc4d6ae0a8a760d7a5a2d Mon Sep 17 00:00:00 2001 From: boudet jean pascal <68547382+atm-jpb@users.noreply.github.com> Date: Wed, 15 May 2024 19:10:14 +0200 Subject: [PATCH] init array_options in current object if we don't have record for it (#29689) * init array_options in current object if we don't have record for it * pre-commit * change '' to null * change comment --------- Co-authored-by: jpb --- htdocs/core/class/commonobject.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) 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