How to set default value to true in Checkbox - Page properties | Community
Skip to main content
varshneyanuj
Level 2
May 30, 2016

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

  • May 30, 2016
  • 3 replies
  • 5497 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

rajkumarsamalaa
Level 2
February 21, 2018

any suggestion, i have same situation ?

Level 3
December 15, 2021

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

July 3, 2023

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"/>