2

Hello I am running an issue right now. I would like to make the checkbox state: checked but I could not make the defaultValue="value"

<channels jcr:primaryType="cq:Widget" fieldLabel="Channels"
                defaultValue="Value" name="channels" options="/bin/sample/private/getJSON.json"
                 optionsValueField="Value" type="checkbox" xtype="selection">

I have tried to do this: Getting Default Checked Checkbox in CQ5

but it didn't solve the issue.

Community
  • 1
  • 1
bluestella
  • 383
  • 2
  • 6
  • 17

3 Answers3

1

This is an example of what I have used to set the default state of the checkbox as 'checked'. Take note of defaultValue="true"

<channels
   jcr:primaryType="cq:Widget"
   fieldLabel="Channels"
   name="channels"
   type="checkbox"
   defaultValue="true"
   xtype="selection"/>
kfaerber
  • 1,327
  • 8
  • 10
1

Try writing it this way.

<channels jcr:primaryType="cq:Widget" 
          fieldLabel="Channels"
          defaultValue="{Boolean}true" 
          name="channels" options="/bin/sample/private/getJSON.json"
          optionsValueField="Value" 
          type="checkbox" 
          xtype="selection">
Chris
  • 4,593
  • 1
  • 33
  • 37
gsquare20
  • 21
  • 1
0

the issue you refer to is to create the checkbox using js / json. if you look at what is actually getting stored in the JCR you will see that the value against a checkbox is not actually a boolean, but is a string. which can be true / flase, or on / off if the item is inside a checkboxgroup.

In your case, to make it automatically checked in your dialog.xml file you need to use checked="true".