feat: collapsible attribute list on article detail via <details> element

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Simon Kuehn 2026-05-18 11:22:07 +00:00
parent 9f64b2c125
commit 945f0479ca
2 changed files with 15 additions and 11 deletions

View file

@ -127,17 +127,7 @@ final class ArticleCrudController extends AbstractCrudController
yield Field::new('attributeValues', new TranslatableMessage('field.attributes', [], 'admin')) yield Field::new('attributeValues', new TranslatableMessage('field.attributes', [], 'admin'))
->onlyOnDetail() ->onlyOnDetail()
->setCustomOption('renderAsHtml', true) ->setTemplatePath('admin/field/attribute_values.html.twig');
->formatValue(static fn ($v, Article $a): string => implode(
' | ',
array_filter(
$a->getAttributeValues()->map(
static fn ($av) => '' !== $av->getValue()
? '<strong>'.$av->getAttributeDefinition()->getName().'</strong>: '.htmlspecialchars($av->getValue())
: ''
)->toArray()
)
));
yield CollectionField::new('attributeValues', new TranslatableMessage('field.attributes', [], 'admin')) yield CollectionField::new('attributeValues', new TranslatableMessage('field.attributes', [], 'admin'))
->onlyOnForms() ->onlyOnForms()

View file

@ -0,0 +1,14 @@
{% set values = entity.instance.attributeValues|filter(av => av.value != '') %}
<details>
<summary style="cursor:pointer;user-select:none;">
{{ values|length }} Attribute
</summary>
<table style="margin-top:.5rem;border-collapse:collapse;width:100%;">
{% for av in values %}
<tr>
<td style="padding:2px 12px 2px 0;font-weight:600;white-space:nowrap;vertical-align:top;">{{ av.attributeDefinition.name }}</td>
<td style="padding:2px 0;vertical-align:top;">{{ av.value }}</td>
</tr>
{% endfor %}
</table>
</details>