How display name of association field and not the number of active choice in easyadmin4 dashboard

451 Views Asked by At

I'm working on a project symfony 6 with easyadmin4.

I have 2 entity with their repository and crud controller for easyadmin :

  • 1 Entity Dish
  • 1 Entity Category

All works great no errors but in the dashboard Easy Admin Display the number of category in the dish but not the Category Name.

i have search during many hours and don't find where is my problem. I have the same problem with my entity Photo who displayed the number of photo uploaded in this dish but don't see the picture as a thunbmails like in the photo part of my admin.

Problem in screenshot.

Tks by advance for your help

In the 2 entity i have

    public function __toString() {
        return $this->name;
    }

I have read doc about field configuration and test different options without any result.

1

There are 1 best solutions below

0
Lubna Altungi On

In your entity controller crud you can add "AssociationField" to count the number of the fields and "ArrayField" to display the names "but in this case you shold add ->hideOnForm()", something like that:

public function configureFields(string $pageName): iterable
{
    yield AssociationField::new('categories')->setFormTypeOptions(['by_reference' => false,]);
    yield ArrayField::new('categories')->hideOnForm();
}