Skip to content

Commit

Permalink
Fixed warning in DateTimeFilterType.php
Browse files Browse the repository at this point in the history
Fixes #6239
  • Loading branch information
alshenetsky committed Apr 1, 2024
1 parent df81f10 commit c8a4b9f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Form/Filter/Type/DateTimeFilterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$builder->addModelTransformer(new CallbackTransformer(
static fn ($data) => $data,
static function ($data) use ($options) {
// symfony form will cut off invalid values, so make sure no warnings will be thrown out:
$data['value'] ??= null;
$data['value2'] ??= null;

if (ComparisonType::BETWEEN === $data['comparison']) {
if (null === $data['value'] || '' === $data['value'] || null === $data['value2'] || '' === $data['value2']) {
throw new TransformationFailedException('Two values must be provided when "BETWEEN" comparison is selected.');
Expand Down

0 comments on commit c8a4b9f

Please sign in to comment.