diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f3bde4fe826..a04e2cc2187 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8116,10 +8116,16 @@ abstract class CommonObject $out .= "\n"; $nbofextrafieldsshown = 0; - $extrafields_collapse_num = ''; $e = 0; // var to manage the modulo (odd/even) + $lastseparatorkeyfound = ''; + $extrafields_collapse_num = ''; + $extrafields_collapse_num_old = ''; + $i = 0; + foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $label) { + $i++; + // Show only the key field in params if (is_array($params) && array_key_exists('onlykey', $params) && $key != $params['onlykey']) { continue; @@ -8154,6 +8160,7 @@ abstract class CommonObject if (empty($perms)) { continue; } + // Load language if required if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) { $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); @@ -8215,14 +8222,19 @@ abstract class CommonObject $extrafield_collapse_display_value = intval($extrafield_param_list[0]); if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) { - $extrafields_collapse_num = $extrafields->attributes[$this->table_element]['pos'][$key]; + //$extrafields_collapse_num = $extrafields->attributes[$this->table_element]['pos'][$key]; + $extrafields_collapse_num = $key; } } } // if colspan=0 or 1, the second column is not extended, so the separator must be on 2 columns $out .= $extrafields->showSeparator($key, $this, ($colspan ? $colspan + 1 : 2), $display_type, $mode); + + $lastseparatorkeyfound = $key; } else { + $collapse_group = $extrafields_collapse_num.(!empty($this->id) ? '_'.$this->id : ''); + $class = (!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : ''); $csstyle = ''; if (is_array($params) && count($params) > 0) { @@ -8293,13 +8305,13 @@ abstract class CommonObject $helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]); if ($display_type == 'card') { - $out .= ''; + $out .= ''; if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER) && ($action == 'view' || $action == 'valid' || $action == 'editline' || $action == 'confirm_valid' || $action == 'confirm_cancel')) { $out .= ''; } $out .= ''; + $out .= '
'; $out .= '
table_element.'_extrafields_'.$key]) || GETPOST('ignorecollapsesetup', 'int')) ? (empty($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key]) ? false : true) : ($extrafield_collapse_display_value == 2 ? false : true)); } + $disabledcookiewrite = 0; if ($mode == 'create') { - $extrafield_collapse_display_value = 0; + // On create mode, force separator group to not be collapsable + $extrafield_collapse_display_value = 1; + $expand_display = true; // We force group to be shown expanded + $disabledcookiewrite = 1; // We keep status of group unchanged into the cookie } $out = '<'.$tagtype.' id="trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'" class="trextrafieldseparator trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'">'; @@ -2004,19 +2008,21 @@ class ExtraFields // Set the collapse_display status to cookie in priority or if ignorecollapsesetup is 1, if cookie and ignorecollapsesetup not defined, use the setup. $this->expand_display[$collapse_group] = $expand_display; - if (!empty($conf->use_javascript_ajax) && $mode != 'create') { + if (!empty($conf->use_javascript_ajax)) { $out .= ''."\n"; $out .= '