From 2fb9c934dff3f1abf4e1396b193d008e161930b9 Mon Sep 17 00:00:00 2001 From: Iwona Just Date: Fri, 27 Jan 2023 12:32:28 +0000 Subject: [PATCH 1/2] don't show the value input for empty/notempty conditions --- src/base/conditions/BaseNumberConditionRule.php | 5 ----- src/base/conditions/BaseTextConditionRule.php | 9 +++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/base/conditions/BaseNumberConditionRule.php b/src/base/conditions/BaseNumberConditionRule.php index ce24a6692be..6560c078b12 100644 --- a/src/base/conditions/BaseNumberConditionRule.php +++ b/src/base/conditions/BaseNumberConditionRule.php @@ -26,11 +26,6 @@ abstract class BaseNumberConditionRule extends BaseTextConditionRule */ public string $maxValue = ''; - /** - * @inheritdoc - */ - protected bool $reloadOnOperatorChange = true; - /** * @inheritdoc */ diff --git a/src/base/conditions/BaseTextConditionRule.php b/src/base/conditions/BaseTextConditionRule.php index 109c4df0e34..66e95c677b3 100644 --- a/src/base/conditions/BaseTextConditionRule.php +++ b/src/base/conditions/BaseTextConditionRule.php @@ -26,6 +26,11 @@ abstract class BaseTextConditionRule extends BaseConditionRule */ public string $value = ''; + /** + * @inheritdoc + */ + protected bool $reloadOnOperatorChange = true; + /** * @inheritdoc */ @@ -68,6 +73,10 @@ protected function inputType(): string */ protected function inputHtml(): string { + // don't show the value input if the condition checks for empty/notempty + if ($this->operator === self::OPERATOR_EMPTY || $this->operator === self::OPERATOR_NOT_EMPTY) { + return ''; + } return Html::hiddenLabel(Html::encode($this->getLabel()), 'value') . Cp::textHtml($this->inputOptions()); From b1f19c969dfe15b414859e4df3967e0341be250f Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Thu, 2 Feb 2023 16:30:36 -0800 Subject: [PATCH 2/2] Release note --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b715ea730b5..14737f34756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Fixed a bug where accessing a custom field’s magic property on an element would return the field’s raw database value rather than `null`, if it didn’t belong to the element’s field layout anymore. ([#12539](https://github.com/craftcms/cms/issues/12539), [#12578](https://github.com/craftcms/cms/pull/12578)) - Fixed a bug where previewing an asset could wipe out all `h1` tags within Redactor fields. ([#12545](https://github.com/craftcms/cms/issues/12545)) - Fixed a bug where `craft\image\Raster::getIsTransparent()` wasn’t working. ([#12565](https://github.com/craftcms/cms/issues/12565)) +- Fixed a bug where textual condition rules were still showing a text input when the “is empty” or “has a value” operators were selected. ([#12587](https://github.com/craftcms/cms/pull/12587)) - Added `craft\helpers\Db::escapeForLike()`. - `craft\services\Assets::getAllDescendantFolders()` now has a `$withParent` argument, which can be passed `false` to omit the parent folder from the results. ([#12536](https://github.com/craftcms/cms/issues/12536)) - Deprecated `craft\helpers\DateTimeHelper::timeZoneAbbreviation()`.