Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

Selectize is a jQuery-based custom
UI control. It's useful for tagging, contact lists, country selectors, and so on. It clocks in at around ~7kb (gzipped). The goal is to provide a solid & usable user-experience with a clean and powerful API.

It's a lot like Chosen, Select2, and Tags Input but with a few advantages. Plugin originally developed by @brianreavis.

Features

  • Clean API & Clean Code — Interface & make modifications to it like a boss. Fully documented on GitHub & inline.
  • Smart Ranking / Multi-property searching — Want to search an item's title and description? No problem. You can even override the scoring function used for sorting if you want to get crazy.
  • Caret between items — Order matters sometimes. Use the [left] and [right] arrow keys to move between items.
  • Select & delete multiple items at once — Hold down [option] on Mac or [ctrl] on Windows to select more than one item to delete.
  • Díåcritîçs supported — Great for international environments.
  • Item creation — Allow users to create items on the fly (and it's async friendly; the control locks until you invoke a callback).
  • Remote data loading — For when you have thousands of options and want them provided by the server as the user types.

Docs

Find out more: https://selectize.github.io/selectize.js/

How to Use

Drupal 7

Simply use the 'selectize' form element, and the provided default settings or you can override the defaults with your own. Most of the plugins for selectize, like remove_button, are supported.

  // vanilla usage
  $form['foo'] = array(
    '#title' => 'Select Something',
    '#type' => 'selectize',
    '#settings' => selectize_default_settings(),
    '#options' => array('' => 'Pick something or enter your own', 1 => 'ABC', 2 => 'DEF', 3 => 'GHI'),
  );

  // or change some of the default configuration
  $form['bar'] = array(
    '#title' => 'Select Something',
    '#type' => 'selectize',
    '#settings' => selectize_default_settings(
       array(
         'create' => TRUE, 
         'delimiter' => ', ',
         'persist' => TRUE,
         'plugins' => array('remove_button')
       )
    ),
   '#options' => array('' => 'Pick something or enter your own', 1 => 'ABC', 2 => 'DEF', 3 => 'GHI'),
  );

Drupal 8

At the top of your file, include the Selectize element class:

use Drupal\selectize\Element\Selectize;

In your form(s) where you want to Selectize an input:

$form['foo'] = array(
  '#type' => 'selectize',
  '#title' => t('Selectize'),
  '#settings' => Selectize::settings(),
  '#options' => array('' => 'Pick something or enter your own', 1 => 'ABC', 2 => 'DEF', 3 => 'GHI'),
);

This will provide a basic Selectized element. You can also include your own settings overrides, like so:

$form['bar'] = array(
  '#type' => 'selectize',
  '#title' => t('Selectize'),
  '#settings' => Selectize::settings(
    array(
      'maxItems' => 5,
      'plugins' => array('remove_button', 'drag_drop'),
    )
  ),
  '#options' => array('' => 'Pick something or enter your own', 1 => 'ABC', 2 => 'DEF', 3 => 'GHI'),
);

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
May 2023
Latest release
3 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core Release date
2.0.x-dev Dev May 4, 2023