diff --git a/api/js/etemplate/et2_extension_customfields.ts b/api/js/etemplate/et2_extension_customfields.ts index 8009a30890..ea9ecd4d39 100644 --- a/api/js/etemplate/et2_extension_customfields.ts +++ b/api/js/etemplate/et2_extension_customfields.ts @@ -232,7 +232,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac { this.options.fields[field_name] = default_tab[1] !== '-non-private'; } - else // non-private cf + else if (this.options.fields[field_name]) // non-private cf { this.options.fields[field_name] = default_tab[1] !== '-private'; } diff --git a/api/src/Etemplate/Widget/Tabbox.php b/api/src/Etemplate/Widget/Tabbox.php index 2c8e896d0f..5909cea4e4 100644 --- a/api/src/Etemplate/Widget/Tabbox.php +++ b/api/src/Etemplate/Widget/Tabbox.php @@ -169,10 +169,16 @@ class Tabbox extends Etemplate\Widget $exclude = self::getElementAttribute($form_name, 'cfExclude') ?? $this->attrs['cfExclude'] ?? null; $exclude = $exclude ? explode(',', $exclude) : []; + $type_filter = self::expand_name(self::getElementAttribute($form_name, 'cfTypeFilter') ?? $this->attrs['cfTypeFilter'] ?? null, + 0, 0, 0, 0, self::$request->content); + $type_filter = $type_filter ? explode(',', $type_filter) : []; + $tabs = $private_tab = $default_tab = []; foreach($cfs as $cf) { - if (in_array($cf['name'], $exclude)) + // if excluded or wrong type --> ignore + if (in_array($cf['name'], $exclude) || + $type_filter && $cf['type2'] && !array_intersect($cf['type2'], $type_filter)) { continue; } @@ -221,10 +227,10 @@ class Tabbox extends Etemplate\Widget if ($tabs || $default_tab || $private_tab) { // pass given cfTypeFilter attribute via content to all customfields widgets (set in api.cf-tab template) - if (($type_filter = self::getElementAttribute($form_name, 'cfTypeFilter') ?? $this->attrs['cfTypeFilter'] ?? null)) + if ($type_filter) { $content = self::$request->content; - $content['cfTypeFilter'] = self::expand_name($type_filter, 0, 0, 0, 0, $content); + $content['cfTypeFilter'] = implode(',', $type_filter); self::$request->content = $content; } // pass cfExclude attribute via content to all customfields widgets (set in api.cf-tab template)