Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Multiple field - Multifield

Avatar

Level 4
<effective-date
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
name="./effectivedate">
<items jcr:primaryType="nt:unstructured">
<start
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="Start"
name="./startdate"/>
<end
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="End"
name="./enddate"/>
</items>
</field>
</effective-date> 

 This is what i have in my dialog box -- When i try to enter the data .. Close the dialog box and reopen it . I dont see the entered data. But when i use 

 

composite="{Boolean}true"

This works fine when the composite flag is true or if one of the field is named as effectivedate . Is there anything that i am missing here ? I dont want to save the information using composite true ..

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@AEMnewbie 

 

Non composite multifield support only support only one field.

Ex.

+ myinput
  - sling:resourceType = "granite/ui/components/coral/foundation/form/multifield"
  + field
    - sling:resourceType = "granite/ui/components/coral/foundation/form/textfield"
    - name = "./pages"

In your case, you have 2 fields in your multifield. You must use composite multifield. 

When you are using composite multifield, you must give name of the mutifiled node which will be created as child node to the component which holds each multifield item.

 

To make it work, your multifield strecture should be like below.

<effective-date
  jcr:primaryType="nt:unstructured"
  composite = true
  sling:resourceType="granite/ui/components/coral/foundation/form/multifield">
  <field
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/container"
    name="./effectivedate">
    <items jcr:primaryType="nt:unstructured">
      <start
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/foundation/form/textfield"
        fieldLabel="Start"
        name="./startdate"/>
      <end
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/foundation/form/textfield"
        fieldLabel="End"
        name="./enddate"/>
    </items>
  </field>
</effective-date> 

View solution in original post

4 Replies

Avatar

Community Advisor

Hi @AEMnewbie 

 

Composite multifield supports nesting another multifield (composite or not). However, non-composite one doesn’t support nesting.

 

Check more here: https://www.adobe.io/experience-manager/reference-materials/6-5/granite-ui/api/jcr_root/libs/granite...

 

Hope this helps.

 

Thanks,

Kiran Vedantam.

Avatar

Level 4

Thanks .Overlooked at this part However, non-composite one doesn’t support nesting.

Avatar

Community Advisor

Hi @AEMnewbie ,

          As per Adobe recommend to AEM 6.5  use composite for multifield.

If you don't want this then you can use older way like acs-common-nested.

 

Regards,

Sanjay

Avatar

Correct answer by
Community Advisor

@AEMnewbie 

 

Non composite multifield support only support only one field.

Ex.

+ myinput
  - sling:resourceType = "granite/ui/components/coral/foundation/form/multifield"
  + field
    - sling:resourceType = "granite/ui/components/coral/foundation/form/textfield"
    - name = "./pages"

In your case, you have 2 fields in your multifield. You must use composite multifield. 

When you are using composite multifield, you must give name of the mutifiled node which will be created as child node to the component which holds each multifield item.

 

To make it work, your multifield strecture should be like below.

<effective-date
  jcr:primaryType="nt:unstructured"
  composite = true
  sling:resourceType="granite/ui/components/coral/foundation/form/multifield">
  <field
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/container"
    name="./effectivedate">
    <items jcr:primaryType="nt:unstructured">
      <start
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/foundation/form/textfield"
        fieldLabel="Start"
        name="./startdate"/>
      <end
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/foundation/form/textfield"
        fieldLabel="End"
        name="./enddate"/>
    </items>
  </field>
</effective-date>