Home › Forums › ACF PRO › Populate Dynamic Select Field › Reply To: Populate Dynamic Select Field
can you clarify a bit on what do you mean by “clear the old values”?
do you mean, don’t populate the previously saved values?
if that’s the case, you can overwrite the “value” key.
add_filter('acf/prepare_field/name=unique_field_name', 'acf_clear_saved_value');
function acf_clear_saved_value($field) {
$field['choices'] = YOUR_DYNAMIC_CHOICES;
// flush/clear the saved value
$field['value'] = null;
// or, set it to whatever the default
$field['value'] = $field['default_value'];
return $field;
}
p.s. In order to “flush/clear” the value, your select field setting needs to have “allow null” enabled.
Cheers
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.