• I had the same need for rendering HTML in select2 fields as in the support forum (https://support.advancedcustomfields.com/forums/topic/allow-select2-fields-to-render-html-again/). After debugging, I came to this solution:

    add_action( 'acf/input/admin_footer', function() {
    ?>
    <script>
    acf.add_filter('select2_args', function( args ){
      args.templateSelection = function (selection) {
        var $selection = jQuery('<span class="acf-selection"></span>');
        // use acf.escHtml(selection.text) instead of acf.strEscape(selection.text))
        $selection.html(acf.escHtml(selection.text));
        $selection.data('element', selection.element);
        return $selection;
      }
      return args;
    });
    </script>
    <?php
    });

    Maybe the ACF team would implement a filter to control the use of acf.escHtml() over acf.strEscape()? That would be really nice and would be more futureproof than overwriting it like this.

    Thanks and kind regards
    Thomas

    The page I need help with: [log in to see the link]

  • The topic ‘Allow select2 fields to render HTML again’ is closed to new replies.