In ACF, the conditional logic for fields is constrained to data found in the other fields in the group. That works for most things.
In this case, I wanted to have an options page for the theme that allowed two different patterns for timeline events. If you choose the “structured events” pattern, I want to hide the generic contents field (one big field) and instead show a set of fields with a lot more specific fields.
The function and filter below will hide the fields tied to the key field_6514218c94d25 if the option setting (structured_events) is set to “yes.” Conversely, it shows them if “no” is selected.
function dlinq_acf_regular_event( $field ) { if( get_field('structured_events', 'options') === 'yes' ) { return false; } return $field;} add_filter('acf/prepare_field/key=field_6514218c94d25', 'dlinq_acf_regular_event');
There’s a similar piece that hides/shows the more detailed fields.