From 40923c6af502663a2f57501a52e4bfa36509573e Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 7 Oct 2022 13:13:59 +0200 Subject: [PATCH] FIX 16.0 - computed extrafields are not displayed if the object has no "classic" extrafields --- htdocs/core/class/commonobject.class.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a1906123f62..cab5a707269 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6031,14 +6031,15 @@ abstract class CommonObject //var_dump('key '.$key.' '.$value.' type='.$extrafields->attributes[$this->table_element]['type'][$key].' '.$this->array_options["options_".$key]); } } + } - // If field is a computed field, value must become result of compute - foreach ($tab as $key => $value) { - if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) { - //var_dump($conf->disable_compute); - if (empty($conf->disable_compute)) { - $this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, ''); - } + // If field is a computed field, value must become result of compute (regardless of whether a row exists + // in the element's extrafields table) + foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { + if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) { + //var_dump($conf->disable_compute); + if (empty($conf->disable_compute)) { + $this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, ''); } } }