easy admin action condition code example
Example: easy admin action condition
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
public function configureActions(Actions $actions): Actions
{
$viewInvoice = Action::new('View Invoice', 'fas fa-file-invoice')
->displayIf(static function ($entity) {
return $entity->isPaid();
});
// in PHP 7.4 and newer you can use arrow functions
// ->displayIf(fn ($entity) => $entity->isPaid())
return $actions
// ...
->add(Crud::PAGE_INDEX, $viewInvoice);
}