Skip to content

Commit

Permalink
bug #6240 Fixed warning in DateTimeFilterType.php (alshenetsky)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.x branch.

Discussion
----------

Fixed warning in DateTimeFilterType.php

Fixes #6239

Commits
-------

c8a4b9f Fixed warning in DateTimeFilterType.php
  • Loading branch information
javiereguiluz committed Apr 16, 2024
2 parents 5e1e6d0 + c8a4b9f commit 24745c5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Form/Filter/Type/DateTimeFilterType.php
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 24745c5

Please sign in to comment.