From f1524372add2ba489e65831cc62f20110f72aec1 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 6 Dec 2021 16:34:50 +0100 Subject: [PATCH 1/2] Fix extrafield showOutputField old syntax always hidden. --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index e73f83d1340..61c40499150 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1514,7 +1514,7 @@ class ExtraFields $label = $this->attribute_label[$key]; $type = $this->attribute_type[$key]; $help = ''; // Not supported with old syntax - $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + $hidden = 0; // hidden option only available for new syntax } if ($hidden) { From fe40668f43998bf28bba206fc4d3ff89516095ed Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 6 Dec 2021 20:32:44 +0100 Subject: [PATCH 2/2] Parameter 4 extrafieldsobjectkey seems to be required now. --- ChangeLog | 1 + htdocs/core/class/extrafields.class.php | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00962b10419..a70ff0d00e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -144,6 +144,7 @@ Following changes may create regressions for some external modules, but were nec * Method getDictvalue has been renamed into getDictionaryValue to match camel case rule. * To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in method executeCLI() available into core/class/utils.class.php +* ExtraFields->showOutputField parameter 4 'extrafieldsobjectkey' is now required diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 61c40499150..4eefdd4c6bc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1488,7 +1488,7 @@ class ExtraFields * @param string $key Key of attribute * @param string $value Value to show * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) - * @param string $extrafieldsobjectkey If defined (for example $object->table_element), function uses the new method to get extrafields data + * @param string $extrafieldsobjectkey Required (for example $object->table_element). * @return string Formated value */ public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '') @@ -1510,11 +1510,9 @@ class ExtraFields $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } else { - // Old usage - $label = $this->attribute_label[$key]; - $type = $this->attribute_type[$key]; - $help = ''; // Not supported with old syntax - $hidden = 0; // hidden option only available for new syntax + // Old usage not allowed anymore + dol_syslog(get_class($this).'::showOutputField extrafieldsobjectkey required', LOG_WARNING); + return ''; } if ($hidden) {