This module provides a Form API select element with icons using jQuery UI.
This module is for developers only. It does not provide any user functionality.
With Select icons you can easily create select element with icons of your choice
using nothing but drupal Forms API and some CSS:
$form['fancy_select'] = [
'#type' => 'select_icons',
'#title' => $this->t('Color'),
'#options' => [
'r' => $this->t('Red'),
'g' => $this->t('Green'),
'b' => $this->t('Blue'),
],
// This is where magic happens:
// CSS classes from 'data-class' attribute are used in JavaScript
// when building jQuery UI selectmenu widget.
'#options_attributes' => [
'r' => new Attribute(['data-class' => ['color', 'red']]),
'g' => new Attribute(['data-class' => ['color', 'green']]),
'b' => new Attribute(['data-class' => ['color', 'blue']]),
],
// Don't forget to add proper CSS that will provide icons.
// It is recommended to use sprite sheets for better performance.
'#attached' => [ 'library' => ['my/colors'] ],
];
Requirements
Similar projects and how they are different
- Select2 Boxes - Select2 Boxes integrates with Select2 library and provides field widget plugins while Select Icons integrates with jQuery UI and is for developer.
Maintainers
Previous maintainers
Project information
Seeking new maintainer
The current maintainers are looking for new people to take ownership.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Site structure
86 sites report using this module
- Created by siliconmind on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
2.0.0
released 24 June 2024
Works with Drupal: ^10.3 || ^11
Install:
Development version: 2.0.x-dev updated 24 Jun 2024 at 16:50 UTC
8.x-1.3
released 19 June 2024
Works with Drupal: ^10 || ^11
Install:
Development version: 8.x-1.x-dev updated 19 Jun 2024 at 19:20 UTC

