diff --git a/Core/Lib/Widget/WidgetDatalist.php b/Core/Lib/Widget/WidgetDatalist.php
index ad959e9df..0deab8d5c 100644
--- a/Core/Lib/Widget/WidgetDatalist.php
+++ b/Core/Lib/Widget/WidgetDatalist.php
@@ -49,8 +49,8 @@ protected function inputHtml($type = 'datalist', $extraClass = '')
$list = $this->fieldname . '-list-' . $this->getUniqueId();
$html = 'inputHtmlExtraParams()
. ' parent="' . $this->parent . '"'
. ' data-field="' . $this->fieldname . '"'
@@ -61,12 +61,8 @@ protected function inputHtml($type = 'datalist', $extraClass = '')
. ' data-limit="' . $this->limit . '"'
. '/>';
- $html .= '';
+ $html .= $this->generateAutocompleteScript($list);
+
return $html;
}
@@ -89,4 +85,37 @@ protected function setSourceData(array $child, bool $loadData = true)
$this->setValuesFromCodeModel($values, $this->translate);
}
}
+
+ /**
+ * Genera el script de autocomplete para el campo input.
+ *
+ * @param $list
+ * @return string
+ */
+ protected function generateAutocompleteScript($list)
+ {
+ $options = array_map(function ($option) {
+ return empty($option['title']) ? $option['value'] : $option['title'];
+ }, $this->values);
+
+ $optionsJson = json_encode($options, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
+
+ return '';
+ }
}