Skip to content
Discussion options

You must be logged in to vote

It is because it tries to render the active filter button (that allows to clear it), but is unable to convert the entity to string.
You can either use choice_label option, like the one you've provided for Symfony Form, or active_filter_formatter:

use Kreyu\Bundle\DataTableBundle\Filter\FilterData;

$builder->addFilter('clients', EntityFilterType::class, [
    'query_path' => 'client.id',
    'form_options' => [
        'class' => Client::class,
        'choice_label' => function (Client $client): string {
            return $client->getId() . ' - ' . $client->getName();
        },
    ],
    'label' => 'Filter on a client',

    // Add this
    'choice_label' => function (Client $client): s…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@LR3my
Comment options

@Kreyu
Comment options

Kreyu Feb 3, 2025
Maintainer

Answer selected by LR3my
@LR3my
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants