Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

How to set default value to true in Checkbox - Page properties

Avatar

Level 2

Hello,

How do we set a default value for the "granite/ui/components/foundation/form/checkbox" in page properties? I've set the value as true but when I open a dialog first time its always un-selected.

Tried using cq:template to set the value but that also didn't set the default value.

Any suggestions?

Thanks in advance.

-Anuj Varshney

3 Replies

Avatar

Level 2

any suggestion, i have same situation ?

Avatar

Level 3

@kautuk_sahni I am also facing this issue, please let us know if it's feasible to preselect checkbox in page properties or not?

Avatar

Level 1

I found this solution Touch UI Checkbox selected by default – AEM Concepts | AEM Tutorial | AEMaaCS.

 

You have to use the defaultChecked attribute. Tried many other solutions but this is the only one that worked. If you're not seeing the change, re-create the page or use a component to test with.

 

<showPhotos
jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
text="Open link in new tab"
name="./newTab"
value="true"
defaultChecked="{Boolean}true"
uncheckedValue="{Boolean}false"
checked="{Boolean}true"/>