I'm updating a metadata schema and need to add an "add language" button so content authors can add additional copies of the section. Can anyone please share an example to make this happen? Thanks.
Solved! Go to Solution.
Views
Replies
Total Likes
OK - here's the code that works:
<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:granite="http://www.adobe.com/jcr/granite/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"> <tabs jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/tabs" size="L"> <items jcr:primaryType="nt:unstructured"> <tab5 granite:rel="aem-assets-metadata-form-tab" jcr:primaryType="nt:unstructured" jcr:title="CompositeMultifield" sling:resourceType="granite/ui/components/coral/foundation/container" listOrder="4"> <items jcr:primaryType="nt:unstructured"> <col1 granite:rel="aem-assets-metadata-form-column" jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/container" listOrder="0"> <items jcr:primaryType="nt:unstructured"> <products jcr:primaryType="nt:unstructured" jcr:title="Custom Title" sling:resourceType="granite/ui/components/coral/foundation/form/multifield" eaem-show-on-collapse="EAEM.showProductName" fieldLabel="Products"> <field jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/container" name="./jcr:content/metadata/licenses"> <items jcr:primaryType="nt:unstructured"> <column jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/container"> <items jcr:primaryType="nt:unstructured"> <product jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/textfield" fieldDescription="Name of Product" fieldLabel="Product Name" name="./jcr:content/metadata/licenses/product"/> <path jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/pathbrowser" fieldDescription="Select Path" fieldLabel="Path" name="./jcr:content/metadata/licenses/path" rootPath="/content"/> <license jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/textfield" fieldDescription="License Id" fieldLabel="License Id" name="./jcr:content/metadata/licenses"/> </items> </column> </items> </field> <granite:data jcr:primaryType="nt:unstructured" metaType="text" type="custom"/> </products> </items> </col1> </items> </tab5> </items> </tabs> </jcr:root>
Hi @joe_s66, please have a look on below link [1] official Adobe documentation, [2] some YouTube video that presents metadata schema extension/configuration process. To achieve similar behavior like the one represented by Person Shown field, you should use Multi Value Text element.
Thanks - I looked at the documentation but don't see any explanation on how to duplicate several fields into a new section using an "add section" button. Also I'm working directly in the XML code, not in the Metadata Schema Form template.
Sorry, I think I misunderstood your question. I thought that you would like to add repeatable field. As far as I know AEM is not providing ability to generate/add dynamically entire section. In other words you probably will need to implement custom form field. Maybe as a starting point you can have a look how OOTB AEM form fields are implemented - you can find them under /libs/dam/gui/coral/components/admin/schemaforms/formbuilder/formfields.
Is it possible to wrap all the components into a "multifield" component that can be repeated? I see this info in the Granite UI documentation:
/libs/granite/ui/components/coral/foundation/form/multifield
Multifield component allows to add/reorder/remove multiple instances of a field. In the simplest case this is a simple form input field (e.g. textfield, textarea) but it can also be a complex component acting as an aggregate of multiple subcomponents (e.g. address entry).
Hi @joe_s66, so the component you are referring to (/libs/granite/ui/components/coral/foundation/form/multifield) is different version of multfield. Which can be used in component dialogs, and yes it allows to wrap multiple elements inside.
However metadata schema is using its own set of components that are stored in other location, e.g. /libs/dam/gui/coral/components/admin/schemaforms/formbuilder/formfields/v2/mvtextfield
Saying that, you can not pick multifield you have mentioned on metadata schema at least directly from Touch UI. But keeping in mind you are working on xml level I think it is worth to try, there is slight chance it will work.
OK - here's the code that works:
<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:granite="http://www.adobe.com/jcr/granite/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"> <tabs jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/tabs" size="L"> <items jcr:primaryType="nt:unstructured"> <tab5 granite:rel="aem-assets-metadata-form-tab" jcr:primaryType="nt:unstructured" jcr:title="CompositeMultifield" sling:resourceType="granite/ui/components/coral/foundation/container" listOrder="4"> <items jcr:primaryType="nt:unstructured"> <col1 granite:rel="aem-assets-metadata-form-column" jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/container" listOrder="0"> <items jcr:primaryType="nt:unstructured"> <products jcr:primaryType="nt:unstructured" jcr:title="Custom Title" sling:resourceType="granite/ui/components/coral/foundation/form/multifield" eaem-show-on-collapse="EAEM.showProductName" fieldLabel="Products"> <field jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/container" name="./jcr:content/metadata/licenses"> <items jcr:primaryType="nt:unstructured"> <column jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/container"> <items jcr:primaryType="nt:unstructured"> <product jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/textfield" fieldDescription="Name of Product" fieldLabel="Product Name" name="./jcr:content/metadata/licenses/product"/> <path jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/pathbrowser" fieldDescription="Select Path" fieldLabel="Path" name="./jcr:content/metadata/licenses/path" rootPath="/content"/> <license jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/textfield" fieldDescription="License Id" fieldLabel="License Id" name="./jcr:content/metadata/licenses"/> </items> </column> </items> </field> <granite:data jcr:primaryType="nt:unstructured" metaType="text" type="custom"/> </products> </items> </col1> </items> </tab5> </items> </tabs> </jcr:root>
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies