Expand my Community achievements bar.

Introducing Adobe LLM Optimizer: Own your brand’s presence in AI-Powered search and discovery

Multifield is not retaining more than one item

Avatar

Level 3

The multifield below is not retaining more than one item. The child node only stores one item in content path. Second item is saved directly on the component node itself. Need guidance in understanding error in the structure
Multifield dialog: 

 <multifieldDialog
                                                    jcr:primaryType="nt:unstructured"
                                                    sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
                                                    composite="{Boolean}true"
                                                    fieldLabel="Items">
                                                <field
                                                        jcr:primaryType="nt:unstructured"
                                                        sling:resourceType="granite/ui/components/coral/foundation/container"
                                                        name="./multifieldAssets">
                                                    <items
                                                            jcr:primaryType="nt:unstructured">

                                                                jcr:primaryType="nt:unstructured"
                                                                sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
                                                                fieldDescription="Enter the title for the icon."
                                                                fieldLabel="Title"
                                                                name="./title"
                                                                required="{Boolean}true"/>

                                                    </items>
                                                </field>
                                            </multifieldDialog>

  

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

3 Replies

Avatar

Community Advisor

Hi @Zendarkke 

Can you try this 

<multifieldDialog
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
    composite="{Boolean}true"
    fieldLabel="Items">
    <field
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/coral/foundation/container"
        name="./multifieldAssets">
        <items
            jcr:primaryType="nt:unstructured">
            <title
                jcr:primaryType="nt:unstructured"
                sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
                fieldDescription="Enter the title for the icon."
                fieldLabel="Title"
                name="./title"
                required="{Boolean}true"/>
        </items>
    </field>
</multifieldDialog>
The multifield issue is likely due to a malformed XML structure. Use the corrected XML provided above, ensuring proper nesting of the textfield under items. 

Thanks ! 

Avatar

Level 3

I made an error while copying the code. The structure you provided is the one that is in use 

Avatar

Community Advisor

Hi @Zendarkke,

Looks like, this is a classic multifield + composite=true in AEM dialogs.

Your multifield is set with composite="{Boolean}true", which means AEM is supposed to create a node per item under the component node, like:

+ your-component
  + multifieldAssets
    + item0
      - title = "Title 1"
    + item1
      - title = "Title 2"

But in your case, you're seeing:

  • One item inside multifieldAssets

  • Another field like title directly on the component node — which is incorrect.

The Problem

Your structure is almost right, but missing proper nesting inside <items>.

Specifically, you should have a container inside <items>, and within that define your form fields.

Try this

Here’s how your dialog should look:

<multifieldDialog
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
    composite="{Boolean}true"
    fieldLabel="Items">
    <field
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/coral/foundation/container"
        name="./multifieldAssets">
        <items jcr:primaryType="nt:unstructured">
            <!-- Wrap fields in a container node -->
            <item
                jcr:primaryType="nt:unstructured"
                sling:resourceType="granite/ui/components/coral/foundation/container">
                <title
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
                    fieldDescription="Enter the title for the icon."
                    fieldLabel="Title"
                    name="./title"
                    required="{Boolean}true"/>
            </item>
        </items>
    </field>
</multifieldDialog>


Hope that helps!

Regards,
Santosh


Santosh Sai

AEM BlogsLinkedIn