Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
AEM Touch UI component dialog checkboxes
<!-- Checked checkbox will result in a String property of "true" -->
<myCheckbox
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/checkbox"
text="My Checkbox"
name="./myCheckbox"
value="true"/>
<!-- Checked checkbox will result in a Boolean property of true-->
<myBooleanCheckbox
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/checkbox"
text="My Boolean Checkbox"
name="./myBooleanCheckbox"
value="true"/>
<myBooleanCheckboxType
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/hidden"
name="./myBooleanCheckbox@TypeHint"
value="Boolean"/>
<!-- Checkbox defaults to checked and saves a Boolean value of true -->
<myCheckbox
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/checkbox"
text="My Checkbox"
name="./myCheckbox"
value="true"
checked="true"/>
<myCheckboxType
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/hidden"
name="./myCheckbox@TypeHint"
value="Boolean"/>
@leoxy520
leoxy520 commented Nov 3, 2016

It doesn't work in a custom multifield..Why doesn't Adobe provide an official multifield widget that we can put anything in? It seems essential to my everyday work. The OOTB one only works with one field, which is pretty useless and all the custom one on the internet will break for one or the other component that we need. I don't want to create my own custom one especially since the Granite API is not documented well, if at all.

@cmrockwell

Thanks for this reference! I've found it useful.

I wouldn't recommend the last example tho. While it does default to true (checked). If the user un-checks the box, submits and opens the dialog again, then it will show the field as checked even though the saved value is false (or missing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment