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

MultiField Widget (When Author enters only one value)

patK-ze1xYs
Level 4
Level 4

dialog.xml

                    <values

           jcr:primaryType="nt:unstructured"

                        fieldLabel=“Values”

                        name="./values"

                        xtype="multifield"/>

JSP 

    <c:forEach items="${properties. values}" var="value" varStatus="loop">

        <c:if test="${loop.index == 0}">

            ${value}

        </c:if>

        <c:if test="${loop.index != 0}">

            and ${value}

        </c:if>

</c:forEach>

 

For this multi-field when author enters only one Value as "Some text , Some text2" 

JSP displays : "Some text  and Some text2" . Adding ',' in the single multifield value converts it to an array (I think) . Is this the default implementation for multifield ? 

But When Author Enters two separate values  for Multi-field :  

"Some text , Some text2  "

"Some text , Some text2 "

JSP displays it correctly : Some text , Some text2 and Some text , Some text2

1 Accepted Solution
leeasling
Correct answer by
Level 8
Level 8

It's a pretty easy fix - in your dialog, change the definition to this:

<values jcr:primaryType="nt:unstructured" fieldLabel=“Values” name="./values" typeHint="String" xtype="multifield"/>

Note the "typeHint" - this forces the value to be saved as a string array when used in a multi-field.

View solution in original post

2 Replies
edubey
Level 10
Level 10

Yup,

I guess we faced similar issue with multifield long back, It would be great to raise a day care ticket for this, seems to be a bug

leeasling
Correct answer by
Level 8
Level 8

It's a pretty easy fix - in your dialog, change the definition to this:

<values jcr:primaryType="nt:unstructured" fieldLabel=“Values” name="./values" typeHint="String" xtype="multifield"/>

Note the "typeHint" - this forces the value to be saved as a string array when used in a multi-field.

View solution in original post