Skip to content

Instantly share code, notes, and snippets.

@Hube2
Created October 15, 2016 13:02
Show Gist options
  • Save Hube2/d4cee2ac6102589dbe8e5ed414454bff to your computer and use it in GitHub Desktop.
Save Hube2/d4cee2ac6102589dbe8e5ed414454bff to your computer and use it in GitHub Desktop.
Cause Tab where error is located to be focused in ACF
acf.add_filter('validation_complete', function( json, $form ){
if(json.errors) {
var field = jQuery('[name="' + json.errors[0].input + '"]', $form).parents('.acf-field');
field = field[field.length - 1];
var tab = jQuery(field, $form).prev('.acf-field-tab').attr('data-key');
jQuery('.acf-tab-wrap a[data-key=' + tab + ']', $form).click();
}
return json;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment