AEM 6.5 multifield is not retaining the text field values

Avatar

Avatar

ravi_shankerj14

Avatar

ravi_shankerj14

ravi_shankerj14

19-03-2020

I have created an multifield component that  stores the  values as string[] in jcr content. But after storing the values when we came back to the dialog the values were not there. Although the values are available in jcr:content of the page.

 

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
cq:showOnCreate="{Boolean}false"
jcr:primaryType="nt:unstructured"
jcr:title="Customizations "
sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<categorycustom
jcr:primaryType="nt:unstructured"
jcr:title="Page Category "
sling:resourceType="granite/ui/components/coral/foundation/form/fieldset">
<items jcr:primaryType="nt:unstructured">
<category
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield">
<field
jcr:primaryType="nt:unstructured"
jcr:title="Category Name"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<category
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldLabel="Category Name"
key="category"
name="./categoryName"/>
</items>
</field>
</category>
</items>
</categorycustom>
<brandcustom
jcr:primaryType="nt:unstructured"
jcr:title="Brand Name"
sling:resourceType="granite/ui/components/coral/foundation/form/fieldset">
<items jcr:primaryType="nt:unstructured">
<brand
jcr:primaryType="nt:unstructured"
jcr:title="Brand Name"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield">
<field
jcr:primaryType="nt:unstructured"
jcr:title="Brand Name"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<brand
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldLabel="Brand Name"
key="brand"
multiple="{Boolean}true"
name="./brandName"/>
</items>
</field>
</brand>
</items>
</brandcustom>
</items>
</column>
</items>
</jcr:root>

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

BrianKasingli

MVP

Avatar

BrianKasingli

MVP

BrianKasingli
MVP

20-03-2020

@ravi_shankerj14 

Give this a try:

 

<labelsCollection
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
    composite="{Boolean}true"
    fieldLabel="Labels Collection"
    name="./labelsCollection">
    <field
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/coral/foundation/container"
        name="./labels">
        <items jcr:primaryType="nt:unstructured">
            <fieldset
                jcr:primaryType="nt:unstructured"
                jcr:title="Label"
                sling:resourceType="granite/ui/components/coral/foundation/form/fieldset">
                <items jcr:primaryType="nt:unstructured">
                    <label
                        jcr:primaryType="nt:unstructured"
                        sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
                        fieldLabel="Label"
                        name="./label"
                        required="true"/>
                </items>
            </fieldset>
        </items>
    </field>
</labelsCollection>

 

Output:

Screenshot 2020-03-20 at 11.37.12.png

 

Answers (1)

Answers (1)

Avatar

Avatar

Suraj_Kamdi

MVP

Avatar

Suraj_Kamdi

MVP

Suraj_Kamdi
MVP

19-03-2020

@ravi_shankerj14 

In the multifield cq:dialog values are stored in node format and not in String [].

<nav
    sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
    fieldLabel="Links"
    jcr:primaryType="nt:unstructured"
    composite="{Boolean}true">
    <field sling:resourceType="granite/ui/components/coral/foundation/container"
            jcr:primaryType="nt:unstructured" 
            name="./multifieldProperties">
        <items jcr:primaryType="nt:unstructured">
            <linkText
                sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
                fieldLabel="Link Text"
                jcr:primaryType="nt:unstructured"
                name="./linkText" />
        </items>
    </field>
</nav>