[Thread Edited By Adobe]
/*Don’t forget to meet and greet your fellow peers virtually by telling them about yourself here.
Go ahead and to it now: https://adobe.ly/3eDnB4v */
Actual Post:
Hi,
Using AEM 6.1, Touch Ui dialogs, I have a checkbox (checked by default).
1. Checkbox is checked (first time, be default)
2. Uncheck the checkbox and submit the dialog
3. Open the dialog, it is still checked.
Question: Is there any way to uncheck the checkbox in Step 3 above
Solved! Go to Solution.
After playing around, here is the approach I use now involves using cq:template to prefill the resource with a checked value. Just make sure the name of the value you are saving, and the value that is set when checked are present in the cq:template.
Component:
cq:dialog:
<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="nt:unstructured" jcr:title="Checkbox" sling:resourceType="cq/gui/components/authoring/dialog" helpPath="en/cq/current/wcm/default_components.html#Image"> <content jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/container"> <layout jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns" margin="{Boolean}false" type="nav"/> <items jcr:primaryType="nt:unstructured"> <column jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/container"> <items jcr:primaryType="nt:unstructured"> <hideMobile jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/checkbox" name="./myValue" text="Check By Default" value="isChecked"/> </items> </column> </items> </content> </jcr:root>
cq:template
<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="nt:unstructured" myValue="isChecked"> </jcr:root>
checkbox.html
<h1>${properties.myValue}</h1>
Which AEM version are you using, I am facing this issue in AEM 6.1. Do you have any idea if there is a day care hotfix for the same or has it been fixed in AEM 6.2? Do let me know.
This worked for me:
<registerNow
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/checkbox"
fieldDescription="When checked, the Register Now section button appears on the page for members to use"
text="Register Now"
name="./registerNow"
value="{Boolean}true"/>
<registerNowType
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/hidden"
name="./registerNow@TypeHint"
value="Boolean"/>
<registerNowDefaultValue
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/hidden"
name="./registerNow@DefaultValue"
value="{Boolean}true" />
Steps to achieve this
Create nt:unstructured node with sling:resourceType = granite/ui/components/foundation/form/checkbox
Add defaultChecked property (boolean) true
Add “uncheckedValue” property. Assign value to it that which should be saved on the node when checkbox is not checked.
Add “value” property. The value of this property will be saved on the node when checkbox is selected.
example:
<checkbox
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/checkbox"
filedDescription="Select Checkbox"
name="./checkBox"
text="Checkbox"
value="true"
defaultChecked="{Boolean}true"
uncheckedValue="false"/>
tried and tested
This worked for me with Coral component:
Add “uncheckedValue” property. Assign value to it that which should be saved on the node when checkbox is not checked.
Can you please suggest how the same works for classic UI in AEM 6.0