LexikFormFilterBundle icon indicating copy to clipboard operation
LexikFormFilterBundle copied to clipboard

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

Open AizeLeOuf opened this issue 4 years ago • 1 comments

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,

AizeLeOuf avatar Nov 05 '21 10:11 AizeLeOuf

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:

  • update your composer.json to allow dbal 3.*
  • or use tag v6.* of the bundle, this tag use doctrine/orm 2.9, and orm 2.9 use dbal < 3

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

gilles-g avatar Nov 25 '21 12:11 gilles-g