Skip to content

About

Embedded lists for EasyAdmin forms: a related entity's own CRUD index, paginated, sorted and with its row actions, inside the edit form.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

easyadmin-embedded-list

easyadmin-embedded-list

Lists inside EasyAdmin forms.
A related entity's own CRUD index · paginated, sorted, with its row actions · upstream EasyAdmin, no fork

CI Docs Latest release Packagist MIT license

Documentation · Getting started · Configuration · JavaScript events


janalis/easyadmin-embedded-list is a Symfony bundle that shows a collection of the entity being edited, in an EasyAdmin form, as the index page of the collection's own CRUD controller: editing an author, you see and manage their books as the book index shows them.

  • The target's own index: its columns, sorting, pagination and row actions, filtered on the edited entity, loaded into the form and kept there as you page and sort.
  • Mapped or computed collections: a Doctrine collection finds its CRUD controller and filter from the mapping; a computed one names them.
  • Row actions in place: a confirmed delete runs without leaving the form and reloads the list; a cancelled confirmation of the page never runs with it.
  • No session lock: each list releases the session as soon as the user is loaded, so the lists of a page load side by side.
  • Configurable: the fragment header and layout, the field's template and columns, filters and batch actions in lists, in-place actions, the session handling.

Install

composer require janalis/easyadmin-embedded-list

Requires PHP 8.4+, Symfony 7.4 or 8, EasyAdmin 5.6+, Doctrine ORM 3 and AssetMapper.

Quick start

The target CRUD controller filters on the association back to the edited entity:

final class BookCrudController extends AbstractCrudController
{
    public function configureFilters(Filters $filters): Filters
    {
        return $filters->add(EntityFilter::new('author'));
    }
}

The edited entity's CRUD controller shows the collection:

use Janalis\EasyAdminEmbeddedList\Field\EmbeddedListField;

final class AuthorCrudController extends AbstractCrudController
{
    public function configureFields(string $pageName): iterable
    {
        yield TextField::new('name');
        yield EmbeddedListField::new('books', 'Books');
        // A collection Doctrine does not map names its CRUD controller and filter.
        yield EmbeddedListField::new('reviews', 'Reviews')
            ->setEmbeddedController(ReviewCrudController::class, 'author')
            ->setVirtual(true);
    }
}

Configuration

Every option has a default; see Configuration.

easyadmin_embedded_list:
    fragment: { header: X-EA-Fragment, filters: false, batch_actions: false }
    field: { columns: 'col-md-7 col-xxl-6' }
    inline_actions: true
    session: true

Contributing

make install
make verify

See CONTRIBUTING.md and the contributor guide.

License

MIT.

About

Embedded lists for EasyAdmin forms: a related entity's own CRUD index, paginated, sorted and with its row actions, inside the edit form.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages