Search code examples
symfonysymfony2-easyadmin

Add custom method and view to entity with EasyAdminBundle


I'm new to symfony and I'm using esayAdminBundle on one of my project and I would like to call a custom method and a custom render inside the list view.

The custom view is easy but my problem it's sending data to this block, did I need to use custom action or something else ? I'm lost on this one.

The final view is the entity list on top and my custom render below.

If anyone of you have a solution I'm here to read it ;)

Thanks !


Solution

  • There are at least two ways to solve this:

    1) You can override the default list.html.twig template (entirely or just for one specific entity, as explained here: https://github.com/javiereguiluz/EasyAdminBundle/blob/master/Resources/doc/book/3-list-search-show-configuration.md#advanced-design-configuration) and then put a render(controller(...)) call in that template to execute your controller.

    2) You could create a custom menu item that points to a specific route of your application (as explained here: https://github.com/javiereguiluz/EasyAdminBundle/blob/master/Resources/doc/book/6-menu-configuration.md). In that controller you execute anything you need and the result is to render a custom template which again extends from the default list.html.twig (to not lose the "list" feature and after that you put your own code).