diff --git a/src/Infrastructure/Http/Controller/Admin/ArticleCrudController.php b/src/Infrastructure/Http/Controller/Admin/ArticleCrudController.php index fc5d47b..b805ff1 100644 --- a/src/Infrastructure/Http/Controller/Admin/ArticleCrudController.php +++ b/src/Infrastructure/Http/Controller/Admin/ArticleCrudController.php @@ -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() - ? ''.$av->getAttributeDefinition()->getName().': '.htmlspecialchars($av->getValue()) - : '' - )->toArray() - ) - )); + ->setTemplatePath('admin/field/attribute_values.html.twig'); yield CollectionField::new('attributeValues', new TranslatableMessage('field.attributes', [], 'admin')) ->onlyOnForms() diff --git a/templates/admin/field/attribute_values.html.twig b/templates/admin/field/attribute_values.html.twig new file mode 100644 index 0000000..950df48 --- /dev/null +++ b/templates/admin/field/attribute_values.html.twig @@ -0,0 +1,14 @@ +{% set values = entity.instance.attributeValues|filter(av => av.value != '') %} + + + {{ values|length }} Attribute + + + {% for av in values %} + + {{ av.attributeDefinition.name }} + {{ av.value }} + + {% endfor %} + +