Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

virtual_select

2 sites Security covered
View on drupal.org

Provides an integration with the Virtual Select library for select form elements.

Features

  • Support more than 100.000 dropdown options.
  • Support multi-select.
  • Support search feature.

Dependencies

This module requires you to install the JavaScript library Virtual Select.

Installation

You can install the module like any other Drupal module. For more information, please consult https://www.drupal.org/docs/extending-drupal/installing-modules.

Composer

It is recommended to install the Virtual Select JavaScript library with Composer.

In the require section of your composer.json, add the virtual-select-plugin JavaScript library.

"require": {
    "drupal/virtual_select": "^1.0.0",
    "npm-asset/virtual-select-plugin": "^1.0.38"
}

In the repositories section of your composer.json, add the asset-packagist repository.

"repositories": [
    {
        "type": "composer",
        "url": "https://asset-packagist.org"
    }
],

In the installer-types section of your composer.json, add the npm-asset type.

"installer-types": [
    "bower-asset",
    "npm-asset"
],

In the installer-paths section of your composer.json, add the virtual select library.

"web/libraries/{$name}": [
    "type:drupal-library",
    "npm-asset/virtual-select-plugin"
],
"vendor/npm-asset/{$name}": [
    "type:npm-asset"
],

Usage

This module provides an implementation for @FormElement and @FieldWidget. You can use the element like any other form element. For more information, please consult https://api.drupal.org/api/drupal/elements.

Example

$form['virtual_select'] = [
  '#type' => 'virtual_select',
  '#title' => $this->t('My Virtual Select element'),
  '#options' => [
    'cheese' => $this->t('Cheese'),
    'eggs' => $this->t('Eggs'),
    'milk' => $this->t('Milk'),
    'rice' => $this->t('Rice'),
    'chicken' => $this->t('Chicken'),
    'bread' => $this->t('Bread'),
  ],
  '#default_value' => ['chicken', 'milk'],
  '#multiple' => TRUE,
  '#placeholder' => $this->t('- Select -'),
  '#search' => TRUE,
  '#show_value_as_tags' => TRUE,
  '#show_selected_options_first' => TRUE,
  '#search_placeholder' => $this->t('Search...'),
  '#show_options_only_on_search' => FALSE,
  '#no_options_text' => $this->t('No options found.'),
  '#select_all_text' => $this->t('Select all'),
  '#all_options_selected_text' => $this->t('All'),
  '#disabled_options' => ['rice', 'bread'],
];

Activity

Total releases
1
First release
Jul 2025
Latest release
8 months ago
Release cadence
Stability
100% stable

Releases

Version Type Release date
1.0.1 Stable Jul 26, 2025