Skip to content
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

Conditionals on Field Not Persisting Correctly #6008

Closed
daylightstudio opened this issue May 6, 2022 · 5 comments · Fixed by #9199
Closed

Conditionals on Field Not Persisting Correctly #6008

daylightstudio opened this issue May 6, 2022 · 5 comments · Fixed by #9199

Comments

@daylightstudio
Copy link

daylightstudio commented May 6, 2022

Bug description

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

  1. Went to fields sets to edit
  2. Clicked on Conditionals for the field I wanted to edit
  3. Added the extra condition and clicked Finish
  4. Clicked saved on next screen
  5. Went back to Conditionals and it overwrote the value previous value with the new value and didn't persist my new condition

This link best explains the steps.

Logs

No response

Versions

Statamic 3.2.39 Pro
Laravel 8.80.0
PHP 7.4.21
aryehraber/statamic-captcha 1.8.0
doublethreedigital/duplicator 2.2.0
rias/statamic-redirect 2.0.0
spatie/statamic-responsive-images 2.10.1
statamic/seo-pro 2.3.2

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

No response

Additional details

No response

@staudenmeir
Copy link

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:

Bildschirmfoto 2022-05-07 um 10 56 41

@jasonvarga
Copy link
Member

Looks like this is a valid problem, but at the moment we don't support having multiple conditions targeting the same field.

@robdekort
Copy link
Contributor

robdekort commented Jun 30, 2022

I just got bitten by this. Is this only when you're targeting the same field?

@jesseleite
Copy link
Member

jesseleite commented 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
Copy link
Contributor

robdekort commented 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.

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

Successfully merging a pull request may close this issue.

6 participants