Problem/Motivation
Adding a datalist form item with an empty #options property or a single item with an empty value, does not render a datalist tag element in html. This is needed if you want to have the options lazy loaded through javascript for example.
For the handling of the #options validation through the underlying textfield core code, we manipulate the #options to always hold an empty element. In the preprocessing we introduced variables to decide wetter or not to render the datalist tag based on the options being empty or not. Because we strip the first empty value element for validation logic, options are never rendered.
Steps to reproduce
Add a datalist type element and set '#options' => [ ' ' => 'Empty value' ].
Proposed resolution
Allow for empty #options lists to be rendered.
Change the validation logic for dealing with empty submits of the text field input.
Remaining tasks
-
User interface changes
-
API changes
-
Data model changes
-
Issue fork datalist-3609534
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
kriboogh commentedComment #6
kriboogh commented