Skip to content

Computed collections ​

A collection Doctrine does not map, such as a getter or a property hook that gathers entities, has no mapping to find its CRUD controller and filter in. Name them:

php
// Author::$reviews gathers the reviews of the author's books.
yield EmbeddedListField::new('reviews', 'Reviews')
    ->setEmbeddedController(ReviewCrudController::class, 'author')
    ->setVirtual(true);

The list is the review index, filtered on its author filter with the edited author's identifier. The filter decides what the list holds, not the getter: the getter is only read on index and detail pages, for its size.

setVirtual(true) keeps EasyAdmin from sorting the index on a property Doctrine does not know.

A mapped collection ignores these options: its mapping decides.

Released under the MIT License.