Support

Account

Home Forums Backend Issues (wp-admin) Custom Multi-select field Reply To: Custom Multi-select field

  • I couldn’t get my field to match ACF exactly but I did make use of select2.js multiselect by adding multiple="multiple" to my <select> element and calling the select2() function on the element after giving it a unique id.

    jQuery(#example).select2()

    I also added data-placeholder="Select" to display placeholder text, and added a CSS rule to ensure the field went full width. Select2 creates another element that you need to apply the style to, but the id of it should be predictable based on the name of the original select element

    #s2id_example { width: 100%; }

    ACF produces a handful of other attributes (data-ui, data-multiple, data-allow_null) for it’s own native multiselect elements, but I haven’t yet figured out what they do and they didn’t seem to make a difference on my own custom select element.