lexik / LexikFormFilterBundle

This Symfony bundle aim to provide classes to build some form filters and then build a doctrine query from this form filter.
MIT License
389 stars 119 forks source link

Using ChoiceFilterType generate: Undefined constant Doctrine\DBAL\Types\Type::STRING #353

Open AizeLeOuf opened 3 years ago

AizeLeOuf commented 3 years ago

Hi everyone,

First of all, many thanks for all the work done in this bundle.

here my issue:

In my entity:

    /**
     * @ORM\Column(type="boolean")
     */
    private $state;

In my form:

$builder->add('state', Filters\ChoiceFilterType::class, [
            'choices'  => [
                'Validated' => true,
                'To validate' => false,
            ],
        ]);

In my controller:

if ($form->isSubmitted() && $form->isValid()) {
            $queryBuilder->addFilterConditions($form, $filterBuilder);
        }

This code generate:

Undefined constant Doctrine\DBAL\Types\Type::STRING

when I submit the form with a valid value (select 'Validated' or 'To Validated'). With null it's ok... Any help on it will be great !

Regards,

gilles-g commented 2 years ago

Hi,

I think it's because of your DBAL version...

Since they include a lot of BC, you need to update to DBAL v3

Two solutions:

But I think I need to add in the composer.json of the bundle a deps with DBAL 3.* :thinking: