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.
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.