<tab_on_off
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
defaultChecked="{Boolean}true"
checked="{Boolean}true"
name="./onoff"
text="Enable to turn On Data"
uncheckedValue="false"
value="true"/>
How to make checkbox default checked this is not working
Solved! Go to Solution.
Hi @Ronnie09
Can you Try the below:-
<tab_on_off
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
fieldLabel="Page value"
name="./onoff"/>
<tab_on_off-default
jcr:primaryType="nt:unstructured"
sling:resourceType="/libs/granite/ui/components/coral/foundation/form/hidden"
name="./onoff@DefaultValue"
value="{Boolean}true"/>
Make sure name property(./onoff) remain the same with @DefaultValue appended in the hidden one.
Hi @Ronnie09
Please use the below code:
<tab_on_off
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
checked="{Boolean}true"
name="./onoff"
text="Enable to turn On Data"
value="true"/>
Checkbox is checked but value it is returning is false
I see using the above code it works and returns the value as true.
Please use the above code only. After adding the code, when you open the dialog, you can see the checkbox value as selected. Now once you save the dialog, you can see the value as true. Until you save the dialog it will not return the value as true.
Please see the link here with official documentation:
Thanks
Hi @Ronnie09
This should work
<tab_on_off
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
name="./onoff"
text="Enable to turn On Data"
value="true"/>
Hi @Ronnie09
Can you Try the below:-
<tab_on_off
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
fieldLabel="Page value"
name="./onoff"/>
<tab_on_off-default
jcr:primaryType="nt:unstructured"
sling:resourceType="/libs/granite/ui/components/coral/foundation/form/hidden"
name="./onoff@DefaultValue"
value="{Boolean}true"/>
Make sure name property(./onoff) remain the same with @DefaultValue appended in the hidden one.
Hi @Ronnie09
Can you please try and update value="{Boolean}true" as well instead of value="true". Do it for uncheckedValue as well or remove it and try.
<tab_on_off jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/checkbox" checked="{Boolean}true" name="./onoff" text="Enable to turn On Data" value="{Boolean}true"/>
Please try below and see how it works.
<message
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
checked="{Boolean}false"
name="./message"
text="Is Active"
uncheckedValue="{Boolean}false"
value="{Boolean}true"/>
Views
Likes
Replies