diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index b128455b8ff..af5122adbc3 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -2189,6 +2189,44 @@ abstract class CommonObject
}
else return 0;
}
+
+ /**
+ * Function to show lines of extrafields with output datas
+ *
+ * @param object $extrafields extrafield Object
+ *
+ * return string
+ */
+ function showOptionals($extrafields)
+ {
+ global $_POST;
+
+ $out = '';
+
+ if (! empty($this->array_options))
+ {
+ foreach($extrafields->attribute_label as $key=>$label)
+ {
+ $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]);
+ if ($extrafields->attribute_type[$key] == 'separate')
+ {
+ $out = $extrafields->showSeparator($key);
+ }
+ else
+ {
+ // Convert date into timestamp format
+ if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
+ {
+ $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->array_options['options_'.$key];
+ }
+ $out .= '
| '.$label.' | ';
+ $out .= $extrafields->showOutputField($key,$value);
+ $out .= ' |
'."\n";
+ }
+ }
+ }
+ return $out;
+ }
/**
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 80a93028a05..98a6c35aa09 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -1247,26 +1247,7 @@ else
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
- foreach($extrafields->attribute_label as $key=>$label)
- {
-
- $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
- if ($extrafields->attribute_type[$key] == 'separate')
- {
- print $extrafields->showSeparator($key);
- }
- else
- {
- // Convert date into timestamp format
- if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
- {
- $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$object->array_options['options_'.$key];
- }
- print '| '.$label.' | ';
- print $extrafields->showOutputField($key,$value);
- print ' |
'."\n";
- }
- }
+ print $object->showOptionals($extrafields);
}
// Note