Skip to content

Update conditional-fields.md to include taxonomy example #1692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions content/collections/docs/conditional-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down