What is an embedded list?
An embedded list shows a collection of the entity being edited as the index page of the collection's own CRUD controller, inside the edit form. Editing an author, you see their books as the book index shows them: the same columns, sorting, pagination and row actions, filtered on that author.
php
use Janalis\EasyAdminEmbeddedList\Field\EmbeddedListField;
public function configureFields(string $pageName): iterable
{
yield TextField::new('name');
yield EmbeddedListField::new('books', 'Books');
}How it works
- On an edit form, the field renders an empty placeholder carrying the URL of the target index, filtered on the edited entity:
/admin/book?filters[author][comparison]==&filters[author][value]=1. embedded-list.jsfetches that URL with theX-EA-Fragment: 1header.- On such a request the bundle renders the index without the dashboard chrome, and without the confirmation, filter and batch modals, whose forms cannot nest inside the edit form. EasyAdmin itself is not changed.
- The script puts the list in the placeholder and keeps its pagination, sorting and forms inside it. Row actions (edit, delete, detail) work as on the index; a confirmed delete runs in place and reloads the list.
On index and detail pages, the field shows the size of the collection.
Requirements
- PHP 8.4 or later
- Symfony 7.4 or 8
- EasyAdmin 5.6 or later
- Doctrine ORM 3
- AssetMapper, which serves the bundle's script
- The target CRUD controller filters on the association back to the edited entity (an
EntityFilter), and the edited entity has a single identifier, read fromgetId()or a publicidproperty.