diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 00ca58aebcb..50f54a87d0e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4901,6 +4901,14 @@ 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) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) + { + $this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0); + } + } } $this->db->free($resql); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 3fcc8532af6..12fa3ea9bc9 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1547,14 +1547,6 @@ class ExtraFields if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method. - // If field is a computed field, value must become result of compute - if ($computed) - { - // Make the eval of compute string - //var_dump($computed); - $value = dol_eval($computed, 1, 0); - } - $showsize=0; if ($type == 'date') {