Skip to content

[6.x] Support for multiple conditions with the same target field#14593

Open
godismyjudge95 wants to merge 1 commit intostatamic:6.xfrom
godismyjudge95:multiple-conditions-per-target-field
Open

[6.x] Support for multiple conditions with the same target field#14593
godismyjudge95 wants to merge 1 commit intostatamic:6.xfrom
godismyjudge95:multiple-conditions-per-target-field

Conversation

@godismyjudge95
Copy link
Copy Markdown
Contributor

This came up in the Statamic Office Hours, and it's something I've personally run into a number of times.

Currently when you want to reveal based on a field being A or B or C. You must create a custom condition because Statamic doesn't support using the same field for multiple conditions. This PR fixes that.

It is completely backwards compatible and simply wraps the right hand side of the condition in an array if there are multiple conditions for the same target field.

This outputs this for multiple conditions:

if:
  age:
    - '> 18'
    - '< 65'

And this for a single condition:

if:
  age: '> 18'

Any previous blueprints with only a single condition will continue to work and if a new condition is added to them it will convert it to the array/list syntax.

Resolves:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant