fix: use Field for attributeValues detail view, render ebayDescription as HTML

TextField rejects Collection values before formatValue runs. Switching to
the generic Field avoids the type check. ebayDescription now renders its
HTML tags in the detail view instead of showing raw markup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Simon Kuehn 2026-05-18 11:15:32 +00:00
parent b908e44a6e
commit ed0caea344

View file

@ -23,6 +23,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\CollectionField;
use EasyCorp\Bundle\EasyAdminBundle\Field\Field;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
@ -119,10 +120,11 @@ final class ArticleCrudController extends AbstractCrudController
yield TextField::new('sku')->hideOnForm()->hideOnIndex();
yield TextField::new('serialNumber', new TranslatableMessage('field.serial_number', [], 'admin'))->setRequired(false)->hideOnIndex();
yield TextField::new('conditionNotes', new TranslatableMessage('field.condition_notes', [], 'admin'))->setRequired(false)->hideOnIndex();
yield TextareaField::new('ebayDescription', new TranslatableMessage('field.ebay_description', [], 'admin'))->setRequired(false)->hideOnIndex();
yield TextareaField::new('ebayDescription', new TranslatableMessage('field.ebay_description', [], 'admin'))->setRequired(false)->hideOnIndex()->renderAsHtml();
yield TextField::new('attributeValues', new TranslatableMessage('field.attributes', [], 'admin'))
yield Field::new('attributeValues', new TranslatableMessage('field.attributes', [], 'admin'))
->onlyOnDetail()
->setCustomOption('renderAsHtml', true)
->formatValue(static fn ($v, Article $a): string => implode(
' | ',
array_filter(