Skip to content

Instantly share code, notes, and snippets.

@garretthyder
Last active October 15, 2019 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garretthyder/260986880eb1095cb0436efae09351f0 to your computer and use it in GitHub Desktop.
Save garretthyder/260986880eb1095cb0436efae09351f0 to your computer and use it in GitHub Desktop.
Enable Support for Required Intl-Tel fields in Groups that are conditionally shown
// Support ACF Intl Tel Address when in conditional group
jQuery(document).ready(function ($) {
$('[data-hiddeninput]').each(function() {
if ( $(this).is(":visible") ) {
$(this).prop('disabled', false);
$(this).removeAttr('disabled');
} else {
$(this).prop('disabled');
$(this).attr('disabled', 'disabled');
}
});
acf.addAction("enable_field/type=group", function( field ) {
field.$el.find('[data-hiddeninput]').prop('disabled', false);
field.$el.find('[data-hiddeninput]').removeAttr('disabled');
});
acf.addAction("disable_field/type=group", function( field ) {
field.$el.find('[data-hiddeninput]').prop('disabled');
field.$el.find('[data-hiddeninput]').attr('disabled', 'disabled');
});
acf.addAction("append_field/type=group", function( field ) {
field.$el.find('[data-hiddeninput]').prop('disabled', false);
field.$el.find('[data-hiddeninput]').removeAttr('disabled');
});
});
@garretthyder
Copy link
Author

Updated to account for Repeaters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment