diff --git a/extension/Documentation/Manual.rst b/extension/Documentation/Manual.rst index 4ea96aed1b1efd1204f679ccd1407639f1efa82b..9bbe84c2b78993825faf2f02f3257444dc2fc11e 100644 --- a/extension/Documentation/Manual.rst +++ b/extension/Documentation/Manual.rst @@ -3458,6 +3458,8 @@ Type: select * *emptyItemAtEnd*: Existence of this item inserts an empty entry at the end of the selectlist. * *emptyHide*: Existence of this item hides the empty entry. This is useful for e.g. Enums, which have an empty entry and the empty value should not be an option to be selected. + * *datalist*: Similar to 'typeAhead'. Enables the user to select a predefined option (sql1, itemList) or supply any + free text. Attention: Safari (and some other) browsers do not support this fully - https://caniuse.com/#search=datalist. .. _`subrecord-option`: diff --git a/extension/Source/core/AbstractBuildForm.php b/extension/Source/core/AbstractBuildForm.php index 15a0ff1db64c5936f822fcc6ff5f8babb81db7c4..7982180395fb8310e55f70a181be84e8183eed5a 100644 --- a/extension/Source/core/AbstractBuildForm.php +++ b/extension/Source/core/AbstractBuildForm.php @@ -2448,9 +2448,17 @@ abstract class AbstractBuildForm { $formElement = HelperFormElement::prepareExtraButton($formElement, false); $attribute .= $this->getAttributeFeMode($formElement[FE_MODE]); - $html = '<select ' . $attribute . '>' . $option . '</select>'; + if (isset($formElement["datalist"])) { + if ($formElement[FE_DYNAMIC_UPDATE] === 'yes') { + throw new UserFormException("Datalist funktionert nicht mit dynamic update", ERROR_NOT_IMPLEMENTED); + } + $datalistId = $formElement[FE_HTML_ID] . '-datalist'; + $html = '<input ' . Support::doAttribute('list', $datalistId) . $attribute . '><datalist ' + . Support::doAttribute('id', $datalistId) . '>' . $option . '</datalist>'; + } else { + $html = '<select ' . $attribute . '>' . $option . '</select>'; + } $html = $html . $this->getHelpBlock() . $formElement[FE_TMP_EXTRA_BUTTON_HTML]; - return $html . $formElement[FE_INPUT_EXTRA_BUTTON_INFO]; }