Select value from xtype selection type checkbox CQ5
Asked Answered
A

3

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.

Alb answered 14/6, 2013 at 9:58 Comment(1)
What does /bin/sample/private/getJSON.json return?Gati
T
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"/>
Truc answered 18/6, 2013 at 20:10 Comment(0)
W
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">
Wozniak answered 9/10, 2013 at 11:22 Comment(0)
A
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".

Ade answered 13/3, 2014 at 21:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.