Home › Forums › Backend Issues (wp-admin) › Allow select2 fields to render HTML again › Reply To: Allow select2 fields to render HTML again
When updated to:
<script>
acf.add_filter('select2_args', function(args) {
args.templateSelection = function(selection) {
var $selection = jQuery('<span class="acf-selection"></span>');
$selection.html(acf.escHtml(selection.text));
$selection.data('element', selection.element);
return $selection;
}
args.templateResult = function(selection) {
var $selection = jQuery('<span class="acf-selection"></span>');
$selection.html(acf.escHtml(selection.text));
$selection.data('element', selection.element);
return $selection;
}
return args;
});
</script>
I renders both the selected value HTML and the HTML in the search result template (if you have HTML there also – like I have to allow icon selection)
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.