Support

Account

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 );