Coral UI多选下拉无法清空所有值,保存后恢复的问题咨询
Fixing the Issue Where AEM Multi-Select Dropdown Won't Save Empty State
Hey there, I’ve run into this exact behavior with AEM’s Granite UI multi-select components before. The problem is that when you deselect all options, the component doesn’t actually submit an empty value to the server—so the backend just keeps the last saved values instead of clearing them. The good news is, you just need to add two simple properties to fix this.
The Solution: Add forceEmptySubmit and emptyText
You’ll want to add these two attributes to your select node:
forceEmptySubmit="{Boolean}true": Forces the component to send an empty value to the server when no options are selectedemptyText="": A required companion property (even with an empty string) to makeforceEmptySubmitwork correctly with the select component
Here’s your updated schema configuration:
<_x0031_480609690955 jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/select" fieldLabel="My Dropdown" multiple="true" name="./jcr:content/metadata/mydropdown" renderReadOnly="true" forceEmptySubmit="{Boolean}true" emptyText=""> <granite:data jcr:primaryType="nt:unstructured" metaType="dropdown"/> <items jcr:primaryType="nt:unstructured"> <_x0031_480609702507 jcr:primaryType="nt:unstructured" text="Value 1" value="value_1"/> <_x0031_480609703314 jcr:primaryType="nt:unstructured" text="Value 2" value="value_2"/> <_x0031_480609706365 jcr:primaryType="nt:unstructured" text="Value 3" value="value_3"/> </items> </_x0031_480609690955>
Why This Works
forceEmptySubmitchanges the component’s default behavior: instead of skipping the field when nothing’s selected, it explicitly sends an empty value. This tells the AEM backend to clear the stored metadata value instead of retaining the last one.emptyTextis a quirk of the Granite UI select component—it needs this property present (even as an empty string) to enable theforceEmptySubmitfunctionality. Without it, the component won’t trigger the empty submission.
After adding these properties, you’ll be able to deselect all options, save, and the dropdown’s value will stay empty instead of reverting to the last saved selection.
内容的提问来源于stack exchange,提问作者Riju Mahna
相关产品推荐
相关产品推荐

