Skip to content

[5.x]: Multiple conditional fields behave peculiarly when the condition of one assesses the state of the other #15104

@JamieC24

Description

@JamieC24

What happened?

Description

I have created an Entry Type that uses an Entries field and a URL field.

The Entries field is conditionally set to appear only when the URL field is empty.

The URL field is conditionally set to appear only when the Entries field is empty.

Both fields are visible to begin with (as expected, as both are empty at this point)

When I populate the URL field, the Entries field disappears (as expected)

When I remove the content from the URL field, the Entries field reappears (as expected)

When I select an Entry from the Entries field, the Entries field disappears and the URL field reappears with the content it had before I removed the content from it.

If I refresh the page, neither of the fields are visible (presumably because the state of both is 'has a value' and the fields are both set to appear only when the other has a state of 'is empty')

Steps to reproduce

  1. Log in to any Craft 5.1.7 install
  2. Create an Entry Type
  3. Save the Entry Type
  4. Create a couple of Entries that use the Entry Type you created
  5. Edit your Entry Type using Settings -> Entry Types -> [Your Entry Type]
  6. Create an Entries field and add it to the "Content" tab of your Entry Type
  7. Create a URL field and add it to the "Content" tab of your Entry Type
  8. Edit the settings of your Entries field by clicking on the three dots on the far right of the field box and selecting "Settings"
  9. Use the "Entry Condition" section to add a rule that maps to your URL field and checks that it "is empty" (the dropdown for this shows as 'relates to' by default)
  10. Repeat this process for the URL field, mapping its conditional rule to the Entries field.
  11. Save your Entry Type
  12. Go to one of the two Entries you created and put something in the URL field (e.g https://www.google.ie/)
  13. Remove the text you've just added by highlighting "https://www.google.ie/" and pressing the backspace key
  14. Your Entries field should reappear now. Click the "Add an entry" button on it, select the other entry you created and click "Select"

Expected Behaviour

When you press "Select", a small representation of the entry you chose should appear under the heading for your Entries field, and the URL field should not be visible

Actual Behaviour

When you press "Select", the Entries field disappears and is replaced by the URL field that has repopulated itself with whatever you populated it with previously (e.g https://www.google.ie/).
If you refresh the page and scroll to where your field was, you should no longer be able to see the Entries field nor the URL field.

Craft CMS version

Craft CMS Pro 5.1.7

PHP version

8.2.0

Operating system and version

MacOS Sonoma 14.5

Database type and version

PostgreSQL 15.8

Image driver and version

No response

Installed plugins and versions

  • CKEditor 4.0.5
  • Feed Me 6.1.0
  • Postmark 3.1.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions