datalist
342 sites
Security covered
What does it do
Adds a form element for a HTML Datalist.
Adds an extra's "clear" field button and basic theming.
It works more or less the same as a select field but this has built in search capabilities.
This is actually better for accessibility and other use cases then for example select2 and others which aren't really accessible (even though they come close).
When providing options to datalist make sure it's an associative array. (Value => label)
The value will be submitted, the label is visible. (This can be tweaked via the use_keys settings).
A Webform element is also present.
A field type is in development.
Usage
<?php
$form['list_of_xxx'] = array(
* '#type' => 'datalist',
* '#options' => [
1 => 'Label 1',
],
* '#title' => 'Title',
* '#required' => TRUE,
* '#....
* );
?>Why?
For accessibility and UX reasons we've switched from select, select2 and others to HTML Datalist.
Supporting organizations
- Federal Police Belgium