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

Command icon 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

kriboogh created an issue. See original summary.

  • kriboogh committed 2fb74e23 on 1.0.x
    fix: #3609534 Datalist tag not rendered when options is empty list or...
kriboogh’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

kriboogh’s picture

Status: Fixed » Closed (fixed)