From 536005ad14c8550a2854688ef2a03b753634e5a8 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 12 Nov 2020 13:38:43 +0100 Subject: [PATCH] Add not equal operator for StringOperatorType (#6585) --- UPGRADE-3.x.md | 4 ++++ src/Form/Type/Operator/StringOperatorType.php | 2 ++ tests/Form/Type/Operator/StringOperatorTypeTest.php | 1 + 3 files changed, 7 insertions(+) diff --git a/UPGRADE-3.x.md b/UPGRADE-3.x.md index bad3950461..0ad4d09be1 100644 --- a/UPGRADE-3.x.md +++ b/UPGRADE-3.x.md @@ -4,6 +4,10 @@ UPGRADE 3.x UPGRADE FROM 3.x to 3.x ======================= +### Sonata\AdminBundle\Form\Type\Operator\StringOperatorType + +Added "Not equal" in the default list for "choices" option in order to allow filtering by strings that are not equal to the model data. + ### Deprecated `Sonata\AdminBundle\Model\ModelManagerInterface::modelTransform()` This method has been deprecated without replacement. diff --git a/src/Form/Type/Operator/StringOperatorType.php b/src/Form/Type/Operator/StringOperatorType.php index 7c165777dc..6804d6d1fc 100644 --- a/src/Form/Type/Operator/StringOperatorType.php +++ b/src/Form/Type/Operator/StringOperatorType.php @@ -25,6 +25,7 @@ final class StringOperatorType extends AbstractType public const TYPE_EQUAL = 3; public const TYPE_STARTS_WITH = 4; public const TYPE_ENDS_WITH = 5; + public const TYPE_NOT_EQUAL = 6; /** * @return void @@ -39,6 +40,7 @@ public function configureOptions(OptionsResolver $resolver) 'label_type_equals' => self::TYPE_EQUAL, 'label_type_starts_with' => self::TYPE_STARTS_WITH, 'label_type_ends_with' => self::TYPE_ENDS_WITH, + 'label_type_not_equals' => self::TYPE_NOT_EQUAL, ], ]); } diff --git a/tests/Form/Type/Operator/StringOperatorTypeTest.php b/tests/Form/Type/Operator/StringOperatorTypeTest.php index 076e2aa25e..726989cf61 100644 --- a/tests/Form/Type/Operator/StringOperatorTypeTest.php +++ b/tests/Form/Type/Operator/StringOperatorTypeTest.php @@ -29,6 +29,7 @@ public function testConfigureOptions(): void 'label_type_equals' => StringOperatorType::TYPE_EQUAL, 'label_type_starts_with' => StringOperatorType::TYPE_STARTS_WITH, 'label_type_ends_with' => StringOperatorType::TYPE_ENDS_WITH, + 'label_type_not_equals' => StringOperatorType::TYPE_NOT_EQUAL, ]; $formType->configureOptions($optionsResolver); $options = $optionsResolver->resolve([]);