Skip to content

[5.x]: Conditionals for relational fields doesn't work across sites #14989

@mmikkel

Description

@mmikkel

What happened?

Description

Relational field conditionals do not work as expected in cases where the relational field contains elements that doesn't exist in the current/active site (i.e. the site for the element being edited).

In the screencast below, I have added an entries field with the "Show site menu" setting checked, and a field layout UI element with an entry condition [Entries Field] is empty. I have two sites, and a section "News" that doesn't propagate.

First, I add an entry to the "Entries Field" field from the same site as the current entry. The UI element disappears, as expected.

Then, I remove the same-site entry, and select a different entry from another site (this entry does not exist in the site for the entry being edited). At this point, the UI element doesn't disappear as expected; I assume because the entries field is still considered "empty" as it has no relations to elements that exists in the site for the entry being edited.

CleanShot.2024-05-14.at.14.48.51.mp4

Steps to reproduce

  1. Create two sites, and a section that doesn't propagate across sites
  2. Create an entries field. Check the "Show site menu" setting
  3. Add the entries field to a field layout, along with a different field layout element (a custom field or UI element). Create an Entry Condition conditional "(entries field) is empty" for the latter.
  4. Edit an entry in one of the site, and select an entry in the entries field that doesn't exist in the site for the entry being edited.

Expected behavior

Relational field conditionals should work regardless of related elements existing in the current entry's site or not.

Actual behavior

Relational field conditionals seem to disregard related elements that do not exist in the site for the element being edited.

Craft CMS version

5.1.2

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

None

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions