Home › Forums › Backend Issues (wp-admin) › Conditional logic from other field group › Reply To: Conditional logic from other field group
Alright, I came up with something if anybody stumbles upon this topic and has the same problem. Basically, I’m hiding the fields I want to disable using CSS when they’re disabled in the main options page.
Here goes in functions.php:
// ACF admin CSS
function acf_css() { ?>
<style type="text/css">
/* checks if option is checked on main option page*/
<?php if (!get_field('papier', 'options')) { ?>
/* hides option in admin */
th[data-name="cache_papier"], td[data-name="cache_papier"] {
display: none;
}
<?php } ?>
</style>
<?php
}
// adds the CSS above to ACF's admin
add_action('acf/input/admin_head', 'acf_css');
Of course you need to replace get_field(‘papier’, ‘options’) for the field that disables the other, as well as data-name=”cache_papier” for the field to hide, with your own names if you do it this way. I hope that’s clear 🙂
It’s not perfect since it’s not actually disabled, it’s just hidden, but it’s better than nothing.
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.