Skip to content

Commit

Permalink
Merge pull request #15781 from craftcms/bugfix/15764-element-conditio…
Browse files Browse the repository at this point in the history
…n-fields-with-the-same-label

condition builder - allow fields with the same label to show (if there’s a hint specified)
  • Loading branch information
brandonkelly authored Sep 23, 2024
2 parents 4285397 + 50b9f53 commit 40f1870
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Element conditions now show rules for fields with the same name but unique handles, if the “Show field handles in edit forms” user preference is enabled. ([#15764](https://github.com/craftcms/cms/issues/15764))
- Auto-generated handles, slugs, etc. now update immediately when the source input is changed. ([#15754](https://github.com/craftcms/cms/issues/15754))
- Fixed a bug where Table fields’ Default Values table could lose existing rows if they only consisted of Dropdown columns without configured options.
- Fixed a bug where custom fields’ `required` properties were always `false`. ([#15752](https://github.com/craftcms/cms/issues/15752))
Expand Down
8 changes: 2 additions & 6 deletions src/elements/conditions/ElementCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,11 @@ protected function selectableConditionRules(): array
$types[] = TitleConditionRule::class;
}

$fieldLabels = [];

foreach ($this->getFieldLayouts() as $fieldLayout) {
foreach ($fieldLayout->getCustomFieldElements() as $layoutElement) {
// Discard fields with empty/non-unique labels
// Discard fields with empty labels
$label = $layoutElement->label();
if ($label === null || isset($fieldLabels[$label])) {
if ($label === null) {
continue;
}
$field = $layoutElement->getField();
Expand All @@ -214,8 +212,6 @@ protected function selectableConditionRules(): array
continue;
}

$fieldLabels[$label] = true;

if (is_string($type)) {
$type = ['class' => $type];
}
Expand Down

0 comments on commit 40f1870

Please sign in to comment.