Handling Optional Field Property - cq:dialog

Avatar

Avatar
Validate 10
Level 2
v1101
Level 2

Likes

4 likes

Total Posts

150 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 10
Level 2
v1101
Level 2

Likes

4 likes

Total Posts

150 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 1
Give Back 5
Give Back 3
View profile
v1101
Level 2

07-01-2021

Hello All - There is a cq:dialog for the page component for capturing the page properties. In that, I have a drop-down with two options for the authors to select and it is not a mandatory field. When the values are not selected, the productType property shouldn't be captured in jcr:content. Could some suggest how to handle this?


<productType
cq:showOnCreate="{Boolean}true"
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/select"
fieldLabel="Product Type"
name="./productType">
<items jcr:primaryType="nt:unstructured">
<household
jcr:primaryType="nt:unstructured"
text="Household"
value="HH"/>
<commercial
jcr:primaryType="nt:unstructured"
text="Commercial"
value="COM"/>
</items>
</productType>

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

192 likes

Total Posts

243 posts

Correct reply

75 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

192 likes

Total Posts

243 posts

Correct reply

75 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile
Ravi_Pampana
MVP

07-01-2021

Hi,

 

As per your xml shared you have two options in the dropdown and by default the first option will be showed when the dialog is opened and when dialog is closed the value will be stored with property name under jcr:content

 

You can add below property to the productType node which will show the place holder text on dialog open and if no value is selected from dropdown, value will not be stored in jcr:content. "Select Value" text can be any value as per your requirement.

 

Screen Shot 2021-01-07 at 5.35.00 PM.png

Dialog will be showed as below

Screen Shot 2021-01-07 at 5.35.53 PM.png

For more options on select refer

 

https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/granite-ui...

Answers (0)