From c3f618465c08de72aa5356af23aa1b03b5c88ee5 Mon Sep 17 00:00:00 2001 From: Eric Celeste Date: Fri, 20 Jun 2025 08:58:45 -0500 Subject: [PATCH] Update conditional-fields.md Seems conditional fields based on taxonomy choices is a pretty common use case. Found this advice at https://github.com/statamic/cms/discussions/7546. --- .../collections/docs/conditional-fields.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/content/collections/docs/conditional-fields.md b/content/collections/docs/conditional-fields.md index 8ae11a03f..0407043bf 100644 --- a/content/collections/docs/conditional-fields.md +++ b/content/collections/docs/conditional-fields.md @@ -137,6 +137,31 @@ If you are dealing with a string value, `contains` and `contains_any` will perfo favorite_food: 'contains_any pizza, lasagna' ``` +### Contains in a Taxonomy + +When you want to compare to a value that resides in a taxonomy, you have to remember that the `contains` term needs to include the taxonomy slug in the form `slug::term`: + +```yaml +- + handle: favorite_food + field: + type: text +- + handle: food_groups + field: + type: terms + taxonomies: + - food_groups + display: Food Groups + mode: select +- + handle: favorite_vegetables + field: + type: text + if: + favorite_food: 'contains food_group::vegetables' +``` + ## Advanced comparisons For more advanced comparisons, several operators and right-hand-side literals/options are available to you. For example, we could show an `email` field if age is greater than or equal to `16`: