Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Empty fields in Drop/Down

Avatar

Former Community Member
How do I add an empty field to a Drop/Down? I want it to be selectable. Currently, once I select a value, and want to go back to empty, there is no way to go back to when nothing was selected.
6 Replies

Avatar

Former Community Member
Nobody knows? Ideally, I would like to click Del after making a selection, this would zero out the drop-down to the empty choice. However, this does not happen. Once you have made a selection, it cannot be removed by keystroke.

Avatar

Former Community Member
Simply add a few spaces to the object>field list items box. Then when you sort your list into alphabetical order, the blank field will appear at the top of the list.

Avatar

Former Community Member
It appears at the top of the list, but it cannot be zeroed out. For instance, I can hit 'Space', and the item that was inserted with addItem("       ", 0), will be selected. But if I use 'Del' key, drop-down will not be zeroed out, if a selection has already been made, and addItem("", 0) was used.

Avatar

Former Community Member
Or forget "Del" key. If i have a drop-down, with



addItem("one");

addItem("two");

addItem("three");



when I load the form, nothing is selected. Once I make a selection, and tab out, I can now never again have an empty selection. I don't know what the solution is, probably is a bug, that drop-downs with non-empty values are shown as empty on form load.

Avatar

Former Community Member
I don't think you can actually create an "empty" field, what I usually do is create a list item with just a space and have that be the first entry. Does this not work for your needs?

Avatar

Former Community Member
It works, but the only way to select this by key is by hitting {Space}. If I add an item with addItem("", 0) {completely empty}. This is not selectable by keystroke.