Home › Forums › Backend Issues (wp-admin) › Show all fields hidden by conditional logic
Hi,
I have a repeater with many different subfields hidden by conditional logic (with different rules for each field). I want to add a true/false that, when on true, show all the fields of the repeater.
So what I could do is add a conditional logic rule to all the fields individually (OR “Show this field îf * true/false* value is equal to checked”) but that adds complexity unnecessarily.
What I could do instead is remove, via javascript, the class .acf-hidden and the attribute hidden from all fields in the group when the true/false is on true.
Questions :
The reason I want to show all the fields with a true/false is because I want all the values to be saved when updating the post (not because I want to see them all at the same time – I would actually hide most fields with a display:none)
– In the conditional logic features, what determines whether wordpress should save the value or not ? Is it the acf-hidden class, the hidden attribute or something else ?
– Could this little hack cause problems somehow? am I better off applying the conditional logic individually?
– Somehow, my javascript code removes the acf-hidden class, but it doesn’t work for the hidden attribute. Is there a problem with my code ?
$(".myrepeater div").removeClass("acf-hidden");
$(".myrepeater div").removeAttribute("hidden");
Thank you !
I used to know how this works but it appears to be far more complicated than just a class now.
fields hidden by ACF have conditional logic
1) The container has a class “acf-hidden”
2) The container has a class “acf-empty”
3) The container has an attribute “hidden”
4) The input field itself has the attribute “disabled”
My guess is that it it #4 that prevents the value from being submitted.
Hi John,
Thank you for your reply. Hmm, what i take from your answer is that it is a bit risky to proceed this way. It’s okay, i can add the conditional rules individually, I just wanted to make it safer/more efficient.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.