I have a select field (field 1) with the options A and B (1A and 1B).
When 1A is selected, a select field (field 2) with options C and D (2C and 2D) is displayed.
When 2D is selected, a text field (field 3) is displayed.
If i select 1A and then 2D but after that i change from 1A to 1B, field 3 will still be displayed!
1A - 2C - 2D - 3 1B
I am using the latest version of WP and ACF.
You’ve confuse me and I don’t really understand by your description what you’re attempting to do.
More than likely what you need to do is add conditions that take all the possible selections into account.
If you can give me a better description of what you want to happen I might be able to help you with the conditions you need to create.
Sorry for the confusion. I will try to be more clear now.
I just need my conditional logic to respect previously selected values.
ACF conditional logic only shows or hides the fields based on selected field values conditions but does not take into account if the field is being shown or not.
I have fields 1<-2<-3 in a certain way that 2 depends on a certain value of 1 and 3 depends on a certain value of 3 (the same as my example above).
If i change the value of 1 not to show 2 anymore, the field 3 will still be visible. This is not right! The value of 2 should not be considered anymore if it is not visible.
The only way to hide 3 again is selecting the right option on 1 to show 2 again and then change the value on 2 not to show 3 anymore.
I hope you understand. Thanks!
I don’t know if this will every change or not. ACF does not check the field the conditional is based on to see if it is not shown, it just checks the value of that field.
So lets say that I have 3 true false fields
The 2nd true or false field is shown if the 1st is set to true.
The 3rd field is shown in the 2nd is set to true.
If I set the 1st one to true and then set the second one to true the 3rd one will be displayed.
If I then set the 1st one to false the 3rd one will still be displayed because the value of the 2nd one is still true, even tough you cannot see it.
Perhaps this is unexpected behavior, but I’m not the developer, I’m just another user so I can’t really make this change.
In order to get this to work the way ACF currently does things you need to take all the conditions that should show a field into account.
The 3rd fields conditionals need to be set so that it only appears if both the 1st field and 2nd field are true.
The other choice is to use tabs. Fields in a tab will respect the conditional of the tab. So if I create 1 true false field and the tab is conditional on this field then any fields inside that tab will also be conditional on that field. This is not due to anything in the conditional logic, it is something that’s dealt with by the tab field.
There are improvements to conditional logic coming in a future update, more field types an things. I don’t know the exact details of these changes at the moment, but I do know that it’s being worked on. The best way to possibly get this changed/added to the improvements would be to submit a new support ticket here https://www.advancedcustomfields.com/contact/ or here https://support.advancedcustomfields.com/new-ticket/
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!
© 2023 Advanced Custom Fields.