- π©πͺGermany Anybody Porta Westfalica
Just came across this and was wondering why it's still required to use a contrib module for datalist: https://www.drupal.org/project/datalist β
I think it would still make a lot of sense to have this available in core. So should we perhaps base this issues MR on that contrib module?datalist is supported by all major browsers: https://caniuse.com/datalist
Many people (at least I think so) will decide against adding a contrib module as additional dependency for this functionality. So I think this, now basic and common, HTML element should be available in Core FAPI.
How should we proceed here?
- ππΊHungary Sweetchuck Budapest
@AnyBody I think that contrib module implements the required functionality in a wring way.
datalist != textfield
- π©πͺGermany Anybody Porta Westfalica
@Sweetchuck I disagree.
See
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist#textu...Recommended values in types text, search, url, tel, email and number, are displayed in a drop-down menu when user clicks or double-clicks on the control.
and
Note: When type is not supported, text type creating simple text field will be used instead. That field will correctly recognize recommended values and display them to the user in a drop-down menu.
$element['#attributes']['type'] = 'text';
is totally fine from my perspective and matches the fallback value (like if no type was set).
Still datalists can also be used on other types, as written in the docs. So for core we could also add this as an extension to other field types.But of course further improvements to the current contrib implementation can be discussed (already in the modules issues).
Would be great to have some more feedback here, how that's expected. Perhaps it should be a core contrib module, like telephone and others? (But definitely in core as W3C standard representation)
- ππΊHungary Sweetchuck Budapest
With that implementation how can you re-use the same datalist for multiple textfields?
- ππΊHungary Sweetchuck Budapest
datalist also can be used for "range" inputs
<label for="tick">Tip amount:</label> <input type="range" list="tickmarks" min="0" max="100" id="tick" name="tick" /> <datalist id="tickmarks"> <option value="0"></option> <option value="10"></option> <option value="20"></option> <option value="30"></option> </datalist>
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist#range...