Multiple field - Multifield | Community
Skip to main content
Level 4
October 22, 2021
Solved

Multiple field - Multifield

  • October 22, 2021
  • 3 replies
  • 2548 views
<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 ..

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Anudeep_Garnepudi

@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> 

3 replies

Kiran_Vedantam
Community Advisor
Community Advisor
October 22, 2021

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/ui/components/coral/foundation/form/multifield/index.html

 

Hope this helps.

 

Thanks,

Kiran Vedantam.

AEMnewbieAuthor
Level 4
October 22, 2021

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

Sanjay_Bangar
Community Advisor
Community Advisor
October 23, 2021

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

Anudeep_Garnepudi
Community Advisor
Anudeep_GarnepudiCommunity AdvisorAccepted solution
Community Advisor
October 23, 2021

@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> 
AG