EasyAdmin Extension provides some useful extensions to EasyAdmin admin generator for Symfony.
❗ This bundle requires at least PHP 7.0 and Symfony 3.0 components or stack.
$ composer require alterphp/easyadmin-extension-bundle
This command requires you to have Composer installed globally, as explained in the Composer documentation.
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new AlterPHP\EasyAdminExtensionBundle\EasyAdminExtensionBundle(),
);
}
// ...
}
- EasyAdmin allows filtering list with
dql_filter
configuration entry. But this is not dynamic and must be configured as an apart list ineasy_admin
configuration.*
This extension allows to dynamically filter lists by adding filters
parameter in the URL parameters. Having a list of books at URL <url-to-admin>?action=list&entity=Book
with a releaseYear fiekd, you can filter on books releasd in 2016 by requesting <url-to-admin>?action=list&entity=Book&filters[entity.releaseDate]=2016
. It only matches exact values, but you can chain them. To request books released in 2015 and 2016, you must request <url-to-admin>?action=list&entity=Book&filters[entity.releaseDate][]=2015&filters[entity.releaseDate][]=2016
.
This filters
parameter is transmitted to the referer used for post update/delete/create redirection AND for search !
You have custom form types that you want to use in the EasyAdmin configuration. You can already register them with FQCN ... but it's quite boring and makes the admin massively enlarged. This feature allows you to define your own form types with short names, by configuration.
Let's see how to register them with those 2 examples (enum and statusable) :
easy_admin_extension:
custom_form_types:
enum: Admin\Form\Type\EnumType
statusable: Admin\Form\Type\StatusableType
Embed your EasyAdmin lists in edit views. This is really useful for *ToMany relations.
First register the form type in the custom_form_types section :
easy_admin_extension:
custom_form_types:
embedded_list: AlterPHP\EasyAdminExtensionBundle\Form\Type\EasyAdminEmbeddedListType
Then use it as a form field :
easy_admin:
entities:
Event:
class: Tm\EventBundle\Entity\Event
Promoter:
class: AppBundle\Entity\Promoter
form:
fields:
# ...
- { type: group, label: Events, css_class: 'col-sm-12', icon: calendar }
- { property: events, label: '', type: embedded_list, type_options: { entity: Event, filters: { 'entity.promoter': 'form:parent.data.id' } } }
Let's see the result !
Run following command :
$ ./vendor/phpunit/phpunit/phpunit
OR using Docker and Docker Compose :
$ docker-compose run --rm phpunit
This software is published under the MIT License