statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
30 stars 1 forks source link

Allow configuring multiple conditions for the same field #1101

Open duncanmcclean opened 6 months ago

duncanmcclean commented 6 months ago

Currently, you can only configure one condition for the same field in the blueprint/fieldset builder.

For example: if you configure two conditions like this on the same field, only one of them will actually be saved in the blueprint:

CleanShot 2023-12-13 at 12 32 16

if:
  title: 'equals bar'

It would be nice if you could configure multiple conditions for a single field. Possibly with options whether the conditions should be AND (must be both foo and bar) / OR (must be either foo or bar).

Related: statamic/cms#6008

duncanmcclean commented 6 months ago

You could workaround this by taking advantage of custom JavaScript conditions to check the field's value against multiple values.

jesseleite commented 1 month ago

Just posting this here for future me, since I was hacking on this little idea a while back...

Could possibly look into adding && and || operators, so you could do things like: some_field: 'not bar && not foo'

I can get that working pretty easily, but obviously we'd need to think a bit more on the UX in the CP for this kind of thing.