Expand my Community achievements bar.

SOLVED

Custom Multifield is not working In AEM 6.3

Avatar

Level 2

Custom Multifield is not working in AEM 6.3

1 Accepted Solution

Avatar

Correct answer by
Level 10

In 6.3, there need to be an update - I have let the team know there is an issue.

View solution in original post

37 Replies

Avatar

Level 2

Thanks smacdonald2008​ and Ratna Kumar​.

Issue is resolved now after installing the instance once again and deploying the helpx article.

Avatar

Level 3

Hi smacdonald2008​, There seems to be an issue with the multifield from both '/libs/granite/ui/components/foundation/form/multifield' and also from '/libs/granite/ui/components/coral/foundation/form/multifield' in handling boolean types.

If I use a 'switch' or a 'checkbox' inside the multifield then the value it takes is always true. I tried with different variations but it doesn't work at all.

Attached images of implementation.

Added the multifield.

1446785_pastedImage_1.png

Added the boolean type switch

1446786_pastedImage_2.png

This is the dialog.

1446787_pastedImage_3.png

Adding values to the dialog. 1st is true, 2nd false and 3rd is true.

1446788_pastedImage_4.png

It stores everything as true :/

1446789_pastedImage_5.png

Any idea what could be causing this ?

Avatar

Level 6

if you define as checkbox, add uncheckedValue there. See an example below.

<hide_image

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"

                        fieldDescription="This checkbox"

                        name="./hideImage"

                        text="Hide Image"

                        uncheckedValue="false"

                        checked="${not empty cqDesign.hideImage ? cqDesign.hideImage : false}"

                        value="true"/>

Avatar

Level 10

How are you reading this value - are you using Sling Model?

Avatar

Level 3

In case of a switch I tried setting a custom value but still no luck. I have created another thread since boolean type issue.

AEM 6.3 Multifield not able to support boolean type resource

1447073_pastedImage_6.png

Its setting the custom set value to all of them. I would expect it to be something like this :

{"firstTitle":"T1", "sale":"enable"}

{"firstTitle":"T2", "sale":" "}

{"firstTitle":"T3", "sale":"enable"}

1447074_pastedImage_7.png

Avatar

Level 3

Reading the value is not a problem for me. I can use the Sling Model, Sightly or ${properties.items} for the same. But this is more when I save the value from dialog itself.

I have opened a thread specifically for boolean type issue so its not mixed with other issue of multifield.

AEM 6.3 Multifield not able to support boolean type resource

I tried setting custom value to switch as replied to BigT168​ in above post but got the same value in all of them in crx.

{"firstTitle":"T1", "sale":"enable"}

{"firstTitle":"T2", "sale":"enable"}

{"firstTitle":"T3", "sale":"enable"}

instead I would expect it to be :

{"firstTitle":"T1", "sale":"enable"}

{"firstTitle":"T2", "sale":" "}

{"firstTitle":"T3", "sale":"enable"}

Avatar

Level 6

can you show me the dialog definition? It should work.

Avatar

Level 10

In this Doc - we cover checkboxes in a MF -- this MF works - See MF Dialog...

pic111.png

Here is the output --

PIC222.png

Avatar

Level 3

This is the definition of the 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="Test Carousel"

    sling:resourceType="cq/gui/components/authoring/dialog"

    helpPath="en/cq/current/wcm/default_components.html#Carousel">

    <content

        jcr:primaryType="nt:unstructured"

        sling:resourceType="granite/ui/components/foundation/container">

        <layout

            jcr:primaryType="nt:unstructured"

            sling:resourceType="granite/ui/components/foundation/layouts/tabs"

            type="nav"/>

        <items jcr:primaryType="nt:unstructured">

            <design

                jcr:primaryType="nt:unstructured"

                jcr:title="Design"

                sling:resourceType="granite/ui/components/foundation/section">

                <layout

                    jcr:primaryType="nt:unstructured"

                    sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"/>

                <items jcr:primaryType="nt:unstructured">

                    <column

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="granite/ui/components/foundation/container">

                        <items jcr:primaryType="nt:unstructured">

                            <layout

                                jcr:primaryType="nt:unstructured"

                                sling:resourceType="granite/ui/components/foundation/form/switch"

                                fieldLabel="Layout"

                                name="./layout"

                                offText="square"

                                onText="portrait"/>

                        </items>

                    </column>

                </items>

            </design>

            <title

                jcr:primaryType="nt:unstructured"

                jcr:title="Title"

                sling:resourceType="granite/ui/components/foundation/section">

                <layout

                    jcr:primaryType="nt:unstructured"

                    sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"/>

                <items jcr:primaryType="nt:unstructured">

                    <column

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="granite/ui/components/foundation/container">

                        <items jcr:primaryType="nt:unstructured">

                            <mainTitle

                                jcr:primaryType="nt:unstructured"

                                sling:resourceType="granite/ui/components/foundation/form/textfield"

                                fieldLabel="Main title"

                                name="./mainTitle"/>

                            <paragraph

                                jcr:primaryType="nt:unstructured"

                                sling:resourceType="granite/ui/components/foundation/form/textfield"

                                fieldLabel="Paragraph"

                                name="./paragraph"/>

                        </items>

                    </column>

                </items>

            </title>

            <itemsBox

                jcr:primaryType="nt:unstructured"

                jcr:title="Items"

                sling:resourceType="granite/ui/components/foundation/section"

                id="itemsTab">

                <layout

                    jcr:primaryType="nt:unstructured"

                    sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"

                    margin="{Boolean}false"/>

                <items jcr:primaryType="nt:unstructured">

                    <column

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="granite/ui/components/foundation/container">

                        <items jcr:primaryType="nt:unstructured">

                            <multiItems

                                jcr:primaryType="nt:unstructured"

                                sling:resourceType="granite/ui/components/coral/foundation/form/multifield"

                                fieldLabel="Add 3 items">

                                <field

                                    jcr:primaryType="nt:unstructured"

                                    sling:resourceType="granite/ui/components/foundation/form/fieldset"

                                    eaem-multifield=""

                                    name="./items">

                                    <layout

                                        jcr:primaryType="nt:unstructured"

                                        sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"/>

                                    <items jcr:primaryType="nt:unstructured">

                                        <column

                                            jcr:primaryType="nt:unstructured"

                                            sling:resourceType="granite/ui/components/foundation/container">

                                            <items jcr:primaryType="nt:unstructured">

                                                <firstTitle

                                                    jcr:primaryType="nt:unstructured"

                                                    sling:resourceType="granite/ui/components/foundation/form/textfield"

                                                    fieldLabel="First Title"

                                                    name="./firstTitle"/>

                                                <sale

                                                    jcr:primaryType="nt:unstructured"

                                                    sling:resourceType="granite/ui/components/coral/foundation/form/switch"

                                                    fieldDescription="Enable this option to apply sale styling to the text."

                                                    fieldLabel="Sale"

                                                    name="./sale"

                                                    offText="Off"

                                                    onText="On"

                                                    value="enable"/>

                                            </items>

                                        </column>

                                    </items>

                                </field>

                            </multiItems>

                        </items>

                    </column>

                </items>

            </itemsBox>

        </items>

    </content>

</jcr:root>

Avatar

Level 3

Hi Scott,

       I see you have selected true value for both the checkboxes. Can you try enabling 1 checkbox and disabling the other and see the output again ?

Also can you share the dialog xml so I can have a look ? Also I wanted to see what would be different when using 'switch'

Tnx

Avatar

Level 6

I think you use mix the foundation class, one with coral and one without coral. I add the sale into my dialog, it works for me. The value is false by default otherwise it is enable.

If you use all coral foundation class in the dialog, the multifield will store each one as node instead string array.

1447620_pastedImage_0.png

1447621_pastedImage_1.png

Avatar

Level 3

Hi BigT168,

           Initially I tried all without coral UI but still I couldn't make it work. I want it i a form of a json so if you say using coral makes it in a node form then I would like to get it work without coral foundation so I can get in form a json in a property. Is that something you have tried ? To get something like below coz that's where things are going bit wrong :

{"firstTitle":"T1", "sale":"enable"}

{"firstTitle":"T2", "sale":"false"}

{"firstTitle":"T3", "sale":"enable"}

Avatar

Level 6

I just tried, it doesn't work without coral foundation.

Avatar

Level 3

Hi BigT168, the issue was with eaem-multifield=“” for coral ui 2. It should be acs-commons-nested=“” in the dialog above when using coral ui2 components.

Coral UI 3 makes it in a form of node and Coral UI 2 keeps it in json format and I wanted it in json.