You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Conditionals on Field Not Persisting Correctly #6008
I wanted to setup multiple conditions on a field so that it would not appear on two different templates. I added the additional condition but it wound up overwriting the previous conditions value and did not add the additional condition. This explains it better:
How to reproduce
Went to fields sets to edit
Clicked on Conditionals for the field I wanted to edit
Added the extra condition and clicked Finish
Clicked saved on next screen
Went back to Conditionals and it overwrote the value previous value with the new value and didn't persist my new condition
We should probably add validation to the conditions builder UX to prevent users from trying this. We could also possibly look into adding && and || operators, so you could do things like: some_field: 'not bar && not foo'.
Activity
staudenmeir commentedon May 7, 2022
This is also happening in
v3.3.10.The underlying issue is that the conditions are keyed by the referenced field and so only one condition is stored per field:
jasonvarga commentedon May 7, 2022
Looks like this is a valid problem, but at the moment we don't support having multiple conditions targeting the same field.
robdekort commentedon Jun 30, 2022
I just got bitten by this. Is this only when you're targeting the same field?
jesseleite commentedon Jun 30, 2022
Yes, you can only set one condition per field.
We should probably add validation to the conditions builder UX to prevent users from trying this. We could also possibly look into adding
&&and||operators, so you could do things like:some_field: 'not bar && not foo'.Until then though, I would suggest using custom JS conditions, as they are very powerful for more complex logic: https://statamic.dev/conditional-fields#custom-logic.
robdekort commentedon Jun 30, 2022
Ah yes. Any of those would be nice. The UI suggests it’s supported indeed. I could work around be reversing the logic in this case 👍.
Thanks for clarifying.