Expand my Community achievements bar.

SOLVED

Trouble making selection-xtype checkbox widget work the way I want

Avatar

Level 7

I want to have a series of checkboxes to let users select one or more social networks (e.g. Facebook, Twitter, and Google+). By default all three should be selected. If I define my widget as follows:

<socialWidgets  jcr:primaryType="cq:Widget" xtype="selection" type="checkbox" options=".../myOptions.json" defaultValue="[facebook,twitter,googleplus]" value="[facebook,twitter,googleplus]" />

When all three items are deselected, rather than submitting a null/empty/blank value, the default value is submitted instead.

What am I doing wrong here?

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 10

You are using default controls. One option you have when working with AEM and xtypes is to develop a custom xtype for finer control. If the default controls do not perform the functionality that you want -- you can gain better control by developing a custom xtype. For information about creating AEM custom xtypes -- see:

http://helpx.adobe.com/experience-manager/using/creating-custom-xtype.html

Now in your custom xtype -- you can use checkboxes. Here is a good community article that talks about how use checkboxes in a custom xtype:

http://aemtips.blogspot.ca/2013/06/how-to-create-custom-xtype-element-for.html

I looked at this one and it works. It created a custom xtype with a checkbox. 

[img]xtypeCHeck.png[/img]

Of course - you can further extend this example to define more checkboxes in the custom xtype: 

http://dev.day.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.Ext.form.Checkbox

Also look at checkboxgroup - here is the API xtype Ref docs:

http://dev.day.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.Ext.form.CheckboxGroup
 

View solution in original post

2 Replies

Avatar

Level 10

For this use case - are you saying that when nothing is selected (you deselcted all values) - the value that is submitted is the default value. I am going to look into this issue. I will post back my findings. 

Avatar

Correct answer by
Level 10

You are using default controls. One option you have when working with AEM and xtypes is to develop a custom xtype for finer control. If the default controls do not perform the functionality that you want -- you can gain better control by developing a custom xtype. For information about creating AEM custom xtypes -- see:

http://helpx.adobe.com/experience-manager/using/creating-custom-xtype.html

Now in your custom xtype -- you can use checkboxes. Here is a good community article that talks about how use checkboxes in a custom xtype:

http://aemtips.blogspot.ca/2013/06/how-to-create-custom-xtype-element-for.html

I looked at this one and it works. It created a custom xtype with a checkbox. 

[img]xtypeCHeck.png[/img]

Of course - you can further extend this example to define more checkboxes in the custom xtype: 

http://dev.day.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.Ext.form.Checkbox

Also look at checkboxgroup - here is the API xtype Ref docs:

http://dev.day.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.Ext.form.CheckboxGroup