Nested multifield in AEM 6.3 + sightly
Multifield dialog-
<?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"
jcr:primaryType="nt:unstructured"
jcr:title="List Collection"
sling:resourceType="cq/gui/components/authoring/dialog">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<tabs
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/tabs"
maximized="{Boolean}true">
<items jcr:primaryType="nt:unstructured">
<Basic
jcr:primaryType="nt:unstructured"
jcr:title="Basic"
sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns"
margin="{Boolean}false">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<enterheadline
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="Please enter headline"
fieldLabel="Enter Headline"
name="./headlineText"/>
<headingurl
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/pathfield"
fieldDescription="Select Link Path"
fieldLabel="Link Url"
name="./headingUrl"/>
<menu
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/multifield"
composite="{Boolean}true"
fieldDescription="Click + to add a new page"
fieldLabel="Multifield collection"
name="./menu">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/fieldset"
multifield-nested=""
name="./items">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"
method="absolute"/>
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<linkurl
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/pathfield"
fieldDescription="Select Link Path"
fieldLabel="Link Url"
name="./linkUrl"/>
<enterlinktext
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="Enter Link Text"
fieldLabel="Enter link text"
name="./linkText"/>
<submenu
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/multifield"
fieldDescription="Add upto 14 links"
fieldLabel="Submenus"
name="./submenussss">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/fieldset"
name="./submenu">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"
method="absolute"/>
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<url
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/pathbrowser"
allowBlank="false"
fieldLabel="Provide navigation link for text"
key="url"
name="./subUrl"/>
<title
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
allowBlank="false"
fieldLabel="Provide navigation text"
key="title"
maxLength="16"
maxLengthText="A maximum of 16 characters is allowed for navigation text"
name="./subTitle"/>
</items>
</column>
</items>
</field>
</submenu>
</items>
</column>
</items>
</field>
</menu>
</items>
</column>
</items>
</Basic>
</items>
</tabs>
</items>
</content>
</jcr:root>
navigation.js
"use strict";
use(function () {
var readJson = null;
var listArr = [];
if (this.fieldValue != '') {
readJson = this.fieldValue;
var count = 0;
if (readJson != null && readJson != "") {
readJson.forEach(function (entry) {
var itemJson = entry;
listArr[count++] = itemJson;
});
}
} else if (this.fieldName != '') {
readJson = granite.resource.properties[this.fieldName];
if (typeof readJson != "undefined" && readJson != null && readJson != "") {
if (readJson.length > 0) {
var count = 0;
readJson.forEach(function (entry) {
var itemJson = JSON.parse(entry);
listArr[count++] = itemJson;
});
} else {
listArr[0] = JSON.parse(readJson);
}
}
}
return {
listJson: listArr
}
});
Sightly: somecomponent.html
<sly data-sly-use.menuInfo="${'navigation.js' @ fieldName = 'items',fieldValue = ''}">
<sly data-sly-list.menuDetails="${menuInfo.listJson}">
<li><a href="${menuDetails.linkUrl}">${menuDetails.linkText}</a>
<ul>
<sly data-sly-use.submenuInfo="${'navigation.js' @ fieldName = '',fieldValue = menuDetails.submenu}">
<sly data-sly-list.innerlistJson="${submenuInfo.listJson}">
${innerlistJson.subTitle}</span></a></li>
</sly>
</sly>
</ul>
</li>
</sly>
</sly>
I have created this without using ACS-common package. hope it will helpful for the community