The issue had come and gone, but has resurfaced again with the latest version of ACF Pro (6.3.8) so I was just revisiting today.
It appears that they have wrapped the localization script for a value (isLicenseActive) that is used by addProLocations in an if (is_admin()) script. (acf-pro.php line 127) So it is not available on the front end causing that js error.
Adding the following to your js enqueue function seems to solve the problem. I am also going to open a bug on the issue.
$to_localize = array(
'isLicenseActive' => acf_pro_is_license_active(),
'isLicenseExpired' => acf_pro_is_license_expired(),
);
acf_localize_data( $to_localize );
Ahah. Was just about to give up and found the solution on StackOverflow.
Need to create the option and pass that to the field first, because ajax.
new Option('label', 'value', true, true);
Creates and sets the value. Huzzah!
if ($("#acf-field_5dcc4aa906709").find("option[value=" + selectedValue + "]").length) {
$('#acf-field_5dcc4aa906709').val([selectedValue]).trigger('change');
} else {
// Create the DOM option that is pre-selected by default
var newCounty = new Option(county, selectedValue, true, true);
// Append it to the select
$("#acf-field_5dcc4aa906709").append(newCounty).trigger('change');
}
Turns out I am having a different issue that is breaking the page.
But that function is still having an error.
in acf-field-groups.js addProLocations function.
ProLocationTypes is null but its object type is still an object. So the Object.entries function is triggering an error.
Ive narrowed this down to a problem with BuddyForms. If I remove the field from the frontend form it works, but when I add it back in, it does not…
I was having the same issue. I did a hard refresh on a wp-admin page and all is working again.
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.