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

Fixes BadRequestHttpException when following the documentation #361

Open Ovski4 opened 2 years ago

Ovski4 commented 2 years ago

Hi,

I was trying to use this bundle with Symfony 6 but ended up with an error as soon as form filters were submitted.

Symfony\Component\HttpKernel\Exception\BadRequestHttpException: Input value "item_filter" contains a non-scalar value.

Following the documentation, I found out the issue came from this line.

// manually bind values from the request
$form->submit($request->query->get($form->getName()));

Since Symfony passed version 6, retrieving non-scalar values using InputBag::get() will throw a BadRequestException. (See changelog here)

From the http foundation package documentation:

// don't use $request->query->get('foo'); use the following instead:
$request->query->all()['foo'];
// returns ['bar' => 'baz']

So this PR fixes the documentation accordingly.