ideas
ideas copied to clipboard
Field conditions on related entries
Following on from this Discord thread, I found it unintuitive how to conditionally show/hide fields based on the value of an Entries field. I tried the docs for Conditional Fields, but it doesn't include this.
Context
- A collection called
Archivehas an entries field calledArchive typewhich allows users to select1(max items) entry from another collection calledArchive type - Elsewhere on the
Archiveblueprint, I need to show/hide fields based on what the user choose inArchive type.- eg: If they choose
Video, then show the fieldVideo meta info - eg: If they choose
Photo, then hide the fieldVideo meta info
- eg: If they choose
Condition that does not work
- My instinct was to set the condition to
equals video, but this doesn't work. - I also stabbed around trying various combinations using
contains,===, prepending with$rootandcollection::archive_type::
Solution / Workaround
- get the
IDof theArchive typeentry ofVideoand usecontainsorcontains_any(comma separating theIDs)
if_any:
archive_type: 'contains_any 7d9c28d8-dfb6-4d73-973f-8936f818109f, 484a539d-640d-4b86-b102-108a1cfbe777'
- The above will show the
Video meta infofield if a user choosesVideoorInterviewfor theArchive type.
I could raise a PR for the docs if someone feels this would be useful. Being able to select the relevant entries in the Conditions UI would be even better, but I'm not sure how many people using this approach.