Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Adding a replicant in the metadata schema

Avatar

Level 3

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.

 

screenshot-2.png

1 Accepted Solution

Avatar

Correct answer by
Level 3

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>

View solution in original post

6 Replies

Avatar

Community Advisor

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.

[1] - https://experienceleague.adobe.com/docs/experience-manager-65/assets/administer/metadata-schemas.htm...

[2] - https://www.youtube.com/watch?v=ZIBpX-g59TQ

Avatar

Level 3

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.

Avatar

Community Advisor

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.

Avatar

Level 3

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).

 

Avatar

Community Advisor

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.

Avatar

Correct answer by
Level 3

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>