I have two ACF Select fields, Grade and Standard.
Based on which Grade and which Standard is selected, a given Taxonomy Multi-Select is displayed using Conditional Logic.
There are about 21 Taxonomies that are presented via Conditional Logic depending on Grade and Standard.
The problem occurs as follows:
1) A user selects a Grade and Standard, selects items from the Taxonomy displayed via Conditional Logic, and then saves a draft or publishes the post.
2) The front end displays the correct Taxonomy items.
3) The user goes back and selects a different Grade or Standard, and selects different items from the newly displayed Taxonomy, then saves a draft or publishes the post.
4) Both the OLD Taxonomy items and the NEW Taxonomy items both display on the front end.
This seems counter-intuitive to me, as due to the Conditional Logic, the “old” Taxonomy field input should be cleared. I can write some PHP logic on the front end that checks the the Grade Level and Standard, and based on that, pulls only the correct Taxonomy item, but I’d like to avoid having to do so if possible. Currently it just sweeps the post_meta for every single taxonomy saved to that post, and displays whatever is saved.
I see your issue. The thing about the conditional fields is that they are more about showing/hiding fields in the backend than deleting information.
Consider a situation where someone want to show different information on a page depending on the season. For this they have radiobuttons to set which season it is and use conditional logic to show different fields (maybe wysiwyg, image field etc.) depending on autumn, winter, spring and summer. This information is the same each year. Then on the front-end they get the value of the radiobutton and show the fields accordingly. This way they can just switch between the different seasons and their information is still there ready to be used.
What I’m trying to say is that it’s not entirely a black/white situation 🙂 I’ve had clients with similar situations as above which would hate it if a condition deleted the information. There’s also the danger of accidentally triggering a conditional (maybe accidentally check a different category on a post) and it would suck to have the content you just put in removed. But I guess you’d also have to save the post..
This is just my thoughts on the subject.
I’ll assign this to @elliot and we’ll see what he thinks 🙂
Totally understand the logic behind it, and agree that the current in-place implementation works as intended! I’ll work on coding a front-end fix that pulls depending on the Grade and Standard selected for the post, instead of just polling every single taxonomy in the post_meta.
Thank you for the quick follow up.
I am looking for the same.
Example: One Price number field, and if 2 other checkboxes (Free, As agreed) are marked Price number field is hidden and value is cleared.
Difficult to make template code with if, else conditional if for instance both Price number field, and Free checkbox field are both with values.
I guess I could solve it with Select field, 3 options and some conditional to show Number Price field if one option is chosen. But it is very strange setting for average Users (building classifieds site).
I just solved it somehow, different way. I did not know one field can be required and not required when hidden by conditional.
– Showing all 3 fields
– Number Price is required, just because I dont have fourth option.
– When any of those 2 yes/no (new style button) are marked Numer Price field is hidden.
– When one yes/no is checked hide other 2.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.