In forms/fields/list/list.html.twig, the collapsible variable is computed inside the {% for key, val in value %} loop (line ~90), which means it is undefined at the time the top block of collection-actions is rendered.
Result : When using controls: both in a blueprint list field, the "Expand All" and "Collapse All" buttons appear correctly at the bottom of the list, but are missing at the top.
To reproduce :
yaml
type: list
style: vertical
controls: both
collapsed: true
btnLabel: 'Add item'
fields:
.field_a:
type: text
label: 'Field A'
.field_b:
type: text
label: 'Field B'
Expected : "Expand All", "Collapse All" and "+ Add item" buttons visible both at top and bottom.
Actual : Only "+ Add item" appears at top. "Expand All" / "Collapse All" are missing at top.
Root cause :
twig
{# In list.html.twig — collapsible is set here, INSIDE the for loop #}
{% for key, val in value %}
{% set collapsible = field.fields|length > 1 and ... %} {# ← too late #}
But the top block is rendered before this loop :
twig{% if fieldControls in ['top', 'both'] %}
<div class="collection-actions">
{% if collapsible %} {# ← undefined here, evaluates to false #}
Fix :
Move the collapsible declaration before {% block contents %} :
twig
{% set fieldControls = field.controls|default('bottom') %}
{# FIX: compute collapsible before block contents so it's available in both top AND bottom collection-actions #}
{% set collapsible = field.fields is defined and field.fields|length > 1 and (field.collapsible is not defined or field.collapsible) %}
{% block contents %}
This one-line move makes collapsible available to both the top and bottom collection-actions blocks without changing any other behavior.
Affected file :
user/plugins/form/templates/forms/fields/list/list.html.twig
(also reproduced in user/plugins/admin/themes/grav/templates/forms/fields/list/list.html.twig)
Grav version : tested on 1.7.x
Plugin form version : tested on current
In
forms/fields/list/list.html.twig, thecollapsiblevariable is computed inside the{% for key, val in value %}loop (line ~90), which means it isundefinedat the time thetopblock ofcollection-actionsis rendered.Result : When using
controls: bothin a blueprint list field, the "Expand All" and "Collapse All" buttons appear correctly at the bottom of the list, but are missing at the top.To reproduce :
Expected : "Expand All", "Collapse All" and "+ Add item" buttons visible both at top and bottom.
Actual : Only "+ Add item" appears at top. "Expand All" / "Collapse All" are missing at top.
Root cause :
Fix :
Move the
collapsibledeclaration before{% block contents %}:This one-line move makes
collapsibleavailable to both thetopandbottom collection-actionsblocks without changing any other behavior.Affected file :
user/plugins/form/templates/forms/fields/list/list.html.twig(also reproduced in
user/plugins/admin/themes/grav/templates/forms/fields/list/list.html.twig)Grav version : tested on 1.7.x
Plugin form version : tested on current