diff --git a/docs/widget-guide.md b/docs/widget-guide.md index dadda4cf..7a1ed850 100644 --- a/docs/widget-guide.md +++ b/docs/widget-guide.md @@ -206,6 +206,40 @@ To use an existing widget in your plugin's `config_schema.json`, simply add the The widget will be automatically rendered when the plugin configuration form is loaded. +## Marking Fields as Advanced (`x-advanced`) + +Add `"x-advanced": true` to any top-level, non-object property to move it out +of the main form and into a single collapsed **Advanced Settings** section at +the bottom of the plugin's configuration page: + +```json +{ + "properties": { + "city": { + "type": "string", + "title": "City" + }, + "request_timeout": { + "type": "integer", + "default": 10, + "description": "HTTP timeout in seconds", + "x-advanced": true + } + } +} +``` + +Guidelines: + +- Use it for fine-tuning knobs most users never touch (timeouts, retry + behavior, cache TTLs, styling overrides). Anything a first-time user must + set to get the plugin working should stay basic. +- Nothing is hidden permanently — the section expands on click, and the + settings search finds and auto-expands advanced fields like any others. +- The flag is ignored on `object`-type properties (they already render as + their own collapsible sections) and is safely ignored by older cores, so + adding it never breaks compatibility. + ## Creating Custom Widgets ### Step 1: Create Widget File diff --git a/web_interface/templates/v3/partials/plugin_config.html b/web_interface/templates/v3/partials/plugin_config.html index e427918f..edb98056 100644 --- a/web_interface/templates/v3/partials/plugin_config.html +++ b/web_interface/templates/v3/partials/plugin_config.html @@ -1005,13 +1005,51 @@ {# Use property order if defined, otherwise use natural order #} {# Skip 'enabled' field - it's handled by the header toggle #} {% set property_order = schema['x-propertyOrder'] if 'x-propertyOrder' in schema else schema.properties.keys()|list %} + {# Flat (non-object) properties flagged "x-advanced": true are + grouped into one collapsed "Advanced Settings" section after + the basic fields. Object-type properties already render as + their own collapsible sections, so the flag is ignored for + them. Schemas without the flag render exactly as before. #} + {% set tiers = namespace(basic=[], advanced=[]) %} {% for key in property_order %} {% if key in schema.properties and key != 'enabled' %} {% set prop = schema.properties[key] %} - {% set value = config[key] if key in config else none %} - {{ render_field(key, prop, value, '', plugin.id) }} + {% set is_object = prop.type is defined and 'object' in prop.type %} + {% if prop.get('x-advanced') and not is_object %} + {% set tiers.advanced = tiers.advanced + [key] %} + {% else %} + {% set tiers.basic = tiers.basic + [key] %} + {% endif %} {% endif %} {% endfor %} + {% for key in tiers.basic %} + {% set prop = schema.properties[key] %} + {% set value = config[key] if key in config else none %} + {{ render_field(key, prop, value, '', plugin.id) }} + {% endfor %} + {% if tiers.advanced %} + {% set adv_section_id = (plugin.id ~ '-section-advanced-settings')|replace('.', '-')|replace('_', '-') %} +
+ + +
+ {% endif %} {% else %} {# No schema - render simple form from config #} {% if config %}