Skip to content

Commit

Permalink
Merge pull request #12587 from craftcms/feature/condition-builder-adj…
Browse files Browse the repository at this point in the history
…ust-ux-empty-notempty

don't show the value input for empty/notempty conditions
  • Loading branch information
brandonkelly authored Feb 3, 2023
2 parents 5b7dbd1 + b1f19c9 commit 90fc9da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.
Expand Down
5 changes: 0 additions & 5 deletions src/base/conditions/BaseNumberConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ abstract class BaseNumberConditionRule extends BaseTextConditionRule
*/
public string $maxValue = '';

/**
* @inheritdoc
*/
protected bool $reloadOnOperatorChange = true;

/**
* @inheritdoc
*/
Expand Down
9 changes: 9 additions & 0 deletions src/base/conditions/BaseTextConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ abstract class BaseTextConditionRule extends BaseConditionRule
*/
public string $value = '';

/**
* @inheritdoc
*/
protected bool $reloadOnOperatorChange = true;

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 90fc9da

Please sign in to comment.