Entries Field: Selectable entries based on value of another field? #12676
-
Well given that WP is heading into a direction which me respectively my client doesn't need or want and were not really satisfied with our current setup anymore I'm currently assessing other options for a possible migration. So far I really like what I see here! I have one question though, please forgive me as I'm still new to Craft CMS. Let's assume the following setup:
It's a basic setup to organize events, their locations and rooms - of course there are other fields, those are just the ones specific to my question. It works perfectly fine like this, however it would be great if the latter Entry Field in Channel Sessions could limit the available entries to the rooms that are actually possible (as in: referencing the correct location that is referenced by the correct event). In a relational database, I'd get the relation of possible rooms through joins (Location, then Event, where Event is the same as the one referenced in the Session), is that possible in the Crafts backend as well? This really is just a minor issue and in no way critical, however I like my backends clean :-) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
This has come up a couple times in our Discord server, and it’s technically possible to pull off with a custom condition rule, but it’s a little hacky. So I just went ahead and made it possible in core, for the upcoming Craft 4.4 release (PR’d at #12679). So once 4.4 is out, you will be able to add a “Related To” condition rule to your “Room” field’s Selectable Entries Condition setting, set to the following template: {event.one().location.one().id} (So you’re saying that only Room entries that are related to the same location as the session’s event.) CleanShot.2023-02-14.at.16.20.05.mp4 |
Beta Was this translation helpful? Give feedback.
-
This is a really nice addition! |
Beta Was this translation helpful? Give feedback.
This has come up a couple times in our Discord server, and it’s technically possible to pull off with a custom condition rule, but it’s a little hacky. So I just went ahead and made it possible in core, for the upcoming Craft 4.4 release (PR’d at #12679).
So once 4.4 is out, you will be able to add a “Related To” condition rule to your “Room” field’s Selectable Entries Condition setting, set to the following template:
(So you’re saying that only Room entries that are related to the same location as the session’s event.)
CleanShot.2023-02-14.at.16.20.05.mp4