Home Forums Backend Issues (wp-admin) Use Select2 instead of browser dropdown


Use Select2 instead of browser dropdown

    • Till

    • May 31, 2019 at 10:06 am

    We’re using a custom select field for our data. How can we make ACF use Select2 for the UI?

    public function render_field($field)
        $field['type'] = 'select';
        $field['ui'] = 0;
        $field['ajax'] = 0;
        $field['multiple'] = 0;
        $field['allow_null'] = 0;
        $field['choices'] = '...redacted...';
  • Is this a custom field type that you are creating?

    I’m not sure that you can use it where you want to use it as this may require adding custom AJAX calls to return the information, however, I don’t know this at all since I’ve never tried to use a select2 field for a custom field type, you’d have to test it to find out.

    At any rate

    $field['ui'] = 1;
    • Till

    • June 16, 2019 at 4:43 am

    I think this needs some kind of JavaScript code to work and not just setting ui to 1 the select doesn’t render.

  • Like I said, it looks like your building a custom field type. I would look at existing field types in ACF to see how the developer does whatever it is that you’re trying to do.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.