diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index c1a76a53a9e..f7eeb005770 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1935,16 +1935,17 @@ class ExtraFields /** * Return HTML string to put an output field into a page * - * @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 Required (for example $object->table_element). - * @param Translate $outputlangs Output language - * @return string Formatted value + * @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 Required (for example $object->table_element). + * @param Translate $outputlangs Output + * @param object $object The parent object of field to show + * @return string Formatted value */ - public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '', $outputlangs = null) + public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '', $outputlangs = null, $object = null) { - global $conf, $langs, $object; + global $conf, $langs; if (is_null($outputlangs) || !is_object($outputlangs)) { $outputlangs = $langs; @@ -2270,10 +2271,10 @@ class ExtraFields if (!empty($classpath)) { dol_include_once($InfoFieldList[1]); if ($classname && class_exists($classname)) { - $object = new $classname($this->db); - '@phan-var-force CommonObject $object'; - $object->fetch($value); - $value = $object->getNomUrl(3); + $tmpobject = new $classname($this->db); + '@phan-var-force CommonObject $tmpobject'; + $tmpobject->fetch($value); + $value = $tmpobject->getNomUrl(3); } } else { dol_syslog('Error bad setup of extrafield', LOG_WARNING); @@ -2303,8 +2304,9 @@ class ExtraFields } elseif ($type == 'password') { $value = dol_trunc(preg_replace('/./i', '*', $value), 8, 'right', 'UTF-8', 1); } elseif ($type == 'stars') { - $value = ''; - $value .= '
'; + $objectid = (int) $object->id; + $value = ''; + $value .= '
'; $i = 1; while ($i <= $size) { $value .= ''.img_picto('', 'fontawesome_star_fas').''; @@ -2313,8 +2315,8 @@ class ExtraFields $value .= '
'; $value .= '