LexikFormFilterBundle
LexikFormFilterBundle copied to clipboard
Fixes BadRequestHttpException when following the documentation
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.