Using Multiselect Module in Drupal 7

The standard multiple select list can be difficult to use, if your users are not very technical. Most of the time they won’t know that you have to hold down command or ctrl key if you want to select multiple options. Also, once you have more than 10 options, the select list becomes very difficult to use. One wrong move and you can loose all the selected options.

The Multiselect module defines a widget that allows users to move selected items from one box to another. Visually this helps users to see which items have been selected. The widget can be used on a bunch of field types and it can be implemented as a form element using FAPI.

If you want to use Multiselect on an entity reference field, then use the 7.x-1.x-dev version.

Getting Started

Download and install the Multiselect module.

Configure Multiselect on Term Reference Field

In this section, we’ll use the Multiselect widget on the Tags field that is created when you install Drupal using the standard installation profile.

1. Structure -> “Content types” and click on “manage fields” within the Article row.

2. Click on Edit within the Tags row and then click on the “Widget tab” in the top right corner.

3. Select Multiselect from the “Widget type” select list and click on Continue.

Fig 1.0

4. Go to Content -> “Add content” and click on Article. Now the Tags widget has changed to a Multiselect widget.

Fig 1.1

Form API Multiselect Widget

You can also use the Multiselect widget on custom forms by defining '#type' => 'multiselect' on a form element. Thankfully, the module ships with “Multiselect FAPI Example” module that shows you a working example.

1. Enable the “Multiselect FAPI Example” module.

2. Go to /multiselect_fapi_example and you should see the example form.

Fig 1.2

Open the multiselect_fapi_example.module file and go to multiselect_fapi_example_display(). In this function you’ll see the multiselector form element.

$form['multiselector'] = array(
  '#type' => 'multiselect',
  '#title' => t('Here is the multiselect'),
  '#options' => array(
    'title' => t('Titles only'),
    'teaser' => t('Titles plus teaser'),
    'fulltext' => t('Full text'),
    '1' => t('Option 1'),
    '2' => t('Option 2'),
  '#default_value' => _multiselect_fapi_example_options(),
  '#multiple' => TRUE,
  '#size' => 15,
  '#required' => TRUE,

If you have any questions, please leave a comment.

15 thoughts on “Using Multiselect Module in Drupal 7”

  1. Very good the tutorial, thanks. I have a question, how can I change the labels “avaible options” and “selected options”?
    Thanks for your help.

    1. You can’t change those labels via a configuration page. However, there are two ways you could do it.

      The first way, is to use the String Overrides ( module. This module allows you to override text that is passed through the “t()” function. This is the least “hacky” way. 🙂

      Another possible option is to use JavaScript to change the labels.

      If you’re curious, look at the _multiselect_build_widget_code() function to see the labels.

  2. David Blankman

    Is there a way to make the multi select widget wider in D6. We are using two fields in a view as the source for the data populating the widget, but not all of the information is visible.

  3. Ivan, thanks for the hint to use the 7.x-1.x-dev version of the module on entity reference fields.
    I was ready to give up and not use the module but then found your posting. Perfect!

  4. In both the example and the on my custom module. The select boxes are not side by side they are on top of each other and neither the Add or Remove links work. Any ideas about what I might be doing wrong?

  5. Hey Ivan,

    thank you for this. Very interesting. I use the multiselect on ‘Entity Reference’ but after ‘Publishing’ and clicling on ‘Edit’ the multiseletc can not show/remember the seletced tags.

    Did you already experiences this issue?



  6. The above code is not working for me.Actually I am very new in Drupal. The first issue is (1)The available options and add/remove button and selected options are displaying one after another.(2)Add and remove not working.Am I missing anything?

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top