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:
parent
9f64b2c125
commit
945f0479ca
2 changed files with 15 additions and 11 deletions
|
|
@ -127,17 +127,7 @@ final class ArticleCrudController extends AbstractCrudController
|
|||
|
||||
yield Field::new('attributeValues', new TranslatableMessage('field.attributes', [], 'admin'))
|
||||
->onlyOnDetail()
|
||||
->setCustomOption('renderAsHtml', true)
|
||||
->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()
|
||||
)
|
||||
));
|
||||
->setTemplatePath('admin/field/attribute_values.html.twig');
|
||||
|
||||
yield CollectionField::new('attributeValues', new TranslatableMessage('field.attributes', [], 'admin'))
|
||||
->onlyOnForms()
|
||||
|
|
|
|||
14
templates/admin/field/attribute_values.html.twig
Normal file
14
templates/admin/field/attribute_values.html.twig
Normal 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>
|
||||
Loading…
Reference in a new issue