Newer
Older
Chosen uses the Chosen js plugin to make your \<select\> elements
(https://github.com/noli42/chosen)
and extract the file under "libraries".
2. Download and enable the module.
3. Configure at Administer > Configuration > User interface > Chosen
(requires administer site configuration permission)
It is assumed you are installing Drupal through Composer using the Drupal
Composer facade. See https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies#drupal-packagist
### Installation with repository entry:
Add the following entry in the "repositories" section of your main composer.json file.
```
{
"type": "package",
"package": {
"name": "noli42/chosen",
"dist": {
"url": "https://github.com/noli42/chosen/releases/download/3.0.0/chosen-assets-v3.0.0.zip",
"type": "zip"
}
}
},
```
Now you can run the following command to install chosen in the right folder:
```
composer require noli42/chosen:3.0.0
```
### Installation with merge plugin:
The Chosen Drupal module is shipped with a "composer.libraries.json" file
which contains information about the chosen library, required by the module itself.
This file should be merged with the project's main composer.json by the aid
of the Composer Merge Plugin available on GitHub. The advantage of this approach is
that the version of the library is defined by the module, and so if the module
updates the version, it will be automatically pulled by composer.
Inside the project directory, open a terminal and run:
Hussain Abbas
committed
```
composer require wikimedia/composer-merge-plugin
Hussain Abbas
committed
```
Then, edit the "composer.json" file of your website and under the "extra"
section add:
Hussain Abbas
committed
```
"merge-plugin": {
"include": [
"web/modules/contrib/chosen/composer.libraries.json"
]
}
Hussain Abbas
committed
```
(*) note: the `web` represents the folder where drupal lives like: ex.
`docroot`.
From now on, every time the "composer.json" file is updated, it will also
read the content of "composer.libraries.json" file located at
web/modules/contrib/chosen/ and update accordingly.
Hussain Abbas
committed
Remember, you may have other entries in there already. For this to work, you
need to have the 'oomphinc/composer-installers-extender' installer. If you
don't have it, or are not sure, simply run:
```
composer require oomphinc/composer-installers-extender
```
Hussain Abbas
committed
Then, run the following composer command:
Hussain Abbas
committed
```
composer require drupal/chosen
```
Hussain Abbas
committed
This command will add the Chosen Drupal module and JavaScript library to your
A Drush command is provided for easy installation of the Chosen plugin.
The command will download the plugin and unpack it in "libraries".
It is possible to add another path as an option to the command, but not
recommended unless you know what you are doing.
If you are using Composer to manage your site's dependencies,
then the Chosen plugin will automatically be downloaded to `libraries/chosen`.
How to exclude a select field from becoming a chosen select.
- go to the configuration page and add your field using the "not"
operator to the textarea with the comma separated values.
For date fields this could look like:
select:not([name*='day'],[name*='year'],[name*='month'])