DEV Community

Javier Eguiluz
Javier Eguiluz

Posted on

New in EasyAdmin 5.8

EasyAdmin 5.8 is out with redesigned badges and automatic filter types for nested properties. But first, a fun fact: this is the 400th release of EasyAdmin since we started the project in 2015. Thanks to everyone who used, tested, reported and contributed during all these years!

Redesigned Badges

Badges are everywhere in EasyAdmin backends: boolean values, statuses, tags, languages, etc. In EasyAdmin 5.8 they have a completely new design. They still look familiar, but they look much better in your backends:

The redesigned badge style in EasyAdmin 5.8

Click to see a higher resolution image and a before/after comparison

The <twig:ea:Badge> component now separates the style of the badge from its color:

  • The variant prop sets the style: light (the default), solid, outline or dot. The default light style is now lighter than before and includes a thin border.
  • The new color prop sets the color (success, danger, warning, etc.). You can also use the new BadgeColor enum for this.
<twig:ea:Badge color="success">Paid</twig:ea:Badge>
<twig:ea:Badge variant="solid" color="danger">Overdue</twig:ea:Badge>
<twig:ea:Badge variant="dot" color="warning">Pending</twig:ea:Badge>
Enter fullscreen mode Exit fullscreen mode

If you prefer a different style, you don't have to change your templates. Call the new setBadgeVariant() method in your dashboard to change all the badges of the backend, or in a CRUD controller to change only the badges of that controller:

use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;

class DashboardController extends AbstractDashboardController
{
    // ...

    public function configureCrud(): Crud
    {
        return Crud::new()
            // possible values: 'light' (default), 'solid', 'outline', 'dot'
            ->setBadgeVariant('solid');
    }
}
Enter fullscreen mode Exit fullscreen mode

A badge that sets its own variant prop keeps it, so you can still use a different style in a specific place.

There are some other improvements too:

  • The new dismissible prop adds a dismiss button to the badge;
  • Icons, images (such as user avatars) and the Flag component now fit nicely inside badges;
  • The lg size of badges now works as expected.

Note: Before, you defined the color of badges with the variant prop (e.g. <twig:ea:Badge variant="success">). This still works, but it's deprecated. Use color="success" instead. If you customized the badge CSS variables, check the UPGRADE guide because some of them changed.

Filter Type Guessing for Nested Properties

EasyAdmin already supported filters on the properties of associated entities and Doctrine embeddables using the dot syntax (author.fullName). However, you had to create the filter yourself, because EasyAdmin only guessed the filter type of the properties of the entity itself.

Before, you had to write this:

public function configureFilters(Filters $filters): Filters
{
    return $filters
        ->add(TextFilter::new('author.fullName'))
        ->add(TextFilter::new('author.address.country'));
}
Enter fullscreen mode Exit fullscreen mode

Now, EasyAdmin reads the Doctrine mapping of the nested property and guesses the filter type, exactly like it does for regular properties:

public function configureFilters(Filters $filters): Filters
{
    return $filters
        // 'author' is an association of the Book entity
        ->add('author.fullName')
        // 'address' is a Doctrine embeddable inside the Author entity
        ->add('author.address.country');
}
Enter fullscreen mode Exit fullscreen mode

You only need to create the filter explicitly when you want to use a different filter or customize its options.

In addition, the date, numeric, text and comparison filters now read the mapping of the nested property too. For example, if birthDate is a date column, DateTimeFilter::new('author.birthDate') now displays a date widget instead of a datetime one.

Behind the Scenes: a New Test Suite

This change doesn't affect your applications at all, but it's a big change for the project: we completely revamped the EasyAdmin test suite.

  • Plain PHPUnit 11: we stopped using simple-phpunit and the PHPUnit bridge. We were stuck on PHPUnit 9.6 and now we use PHPUnit 11 directly.
  • Foundry for fixtures: before, tests used big generic Doctrine Fixtures shared by all tests. Now, every test starts with empty tables and creates only the data it needs using Foundry factories. Combined with DAMA DoctrineTestBundle, which rolls back the database after each test.
  • Multiple databases: the functional tests used to run only on SQLite. Now they also run on PostgreSQL, MySQL and MariaDB in our CI. This already paid off: it found two bugs in ArrayFilter that are fixed in this release.

If you write tests for your Symfony applications, I recommend you to try Foundry. Your tests will be much easier to read and maintain, because each test clearly shows the data it needs.


Support EasyAdmin development:

⭐ Upgrade to EasyAdmin Pro for advanced features like Audit Log and Content Lock
❤️ Become a sponsor if EasyAdmin helps your company ship faster

Top comments (2)

Collapse
 
stivenllupa profile image
Stiven Llupa •

test suite updates look awesome!

Collapse
 
javiereguiluz profile image
Javier Eguiluz •

Thanks! I love Foundry (and Doctrine Test Bundle). I use it in all my work applications, so I wanted to also use it here ... and we finally could do it.