This fixed it which means I was wrong in my assumptions above. I just basically overwrote the existing locations array and everything works fine:
add_filter( 'acf/validate_field_group', 'add_custom_location_dynamic', 10, 1 );
function add_custom_location_dynamic( $field_group ) {
if ( $field_group['key'] === 'group_6786e0728946a' ) {
// This line below clears any existing locations
$field_group['location'] = array();
$currentYear = get_field('current_year', 'option');
$awardArgs = createYearArray($currentYear);
// $awardArgs is just an array of ["2024", "2025"]
$x=0;
foreach($awardArgs as $year) {
$field_group['location'][$x][] = array(
'param' => 'post_type',
'operator' => '==',
'value' => 'entrant_'.$year,
);
$x++;
}
}
return ($field_group);
}
Hope that helps anyone else looking for this.
Found it. In functions.php:
add_action('admin_head', 'my_custom_css');
function my_custom_css() {
echo '<style>
.clear-left {
clear:left !important;
}
</style>';
}
Ha found it. It’s already built in to add a new choice!
Well I didn’t expect it to be that easy. Thanks very much John. You’ve made my day.
Same issue here. If it’s not a bug and something I’m doing wrong (quite possibly), is there a quick tutorial on how to do this? Can’t find anything.
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.