Trouble making selection-xtype checkbox widget work the way I want | Community
Skip to main content
LinearGradient
New Participant
October 16, 2015
Solved

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

  • October 16, 2015
  • 2 replies
  • 1154 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

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
 

2 replies

smacdonald2008
New Participant
October 16, 2015

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. 

smacdonald2008
smacdonald2008Accepted solution
New Participant
October 16, 2015

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