Home › Forums › Bug Reports › ACF Form Conditional Display › Reply To: ACF Form Conditional Display
For anyone suffering from this, I have a workaround that helps my particular case until the bug is fixed. This basically triggers a javascript “change” event on the Select2 component, which snaps the conditional logic into shape. This will only work for when there is at least one item in the select.
function acf_fix_select2( $field ) {
if (
!$field['ui'] || // field isn't select2
strpos( $field['id'], 'acfcloneindex' ) // field is hidden <select>
) {
return;
}
?>
<script type="text/javascript">
jQuery(function(){
jQuery('#s2id_<?php echo $field['id']; ?> .select2-choices input:first')
.trigger('change');
acf.unload.off();
});
</script>
<?php
}
add_action( 'acf/render_field/type=select', 'acf_fix_select2', 10, 1 );
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.