Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Selection in custom xtype not saving

mdp3
Level 1
Level 1

Hey y'all,

I have a custom xtype that I'm making that incorporates a selection of a document type as one of the fields. See code below. The problem is that this field's selection is not getting saved anywhere. I've debugged the js for my custom xtype and the "value" of typeField is never anything other than undefined or "", even when I make a selection. Any idea what could be going on here? Is selection somehow incompatible with custom xtypes or is there something else I need to do or is wrong. Appreciate any help in advance! Thank you!

 

//code this.typeField = new CQ.form.Selection({ type:"select", name: "./testTypeField", fieldDescription: "Choose Attachment Type", options: [ { value: "doc", text: "DOC" }, { value: "pdf", text: "PDF" }, { value: "xls", text: "XLS" }, { value: "zip", text: "ZIP" } ], listeners: { change: { scope:this, fn:this.updateHidden } } }); //more code
1 Accepted Solution
Ojjis
Correct answer by
Level 7
Level 7

Hi there,
It looks like (when comparing to other standard widgets that use the CQ.form.Selection) that you have used "changed" instead of "selectionchanged" for the listener. If that was the case that you needed that it would explain why the listener event was not fired. Then no new value would be saved and since you did not specify a default value (like: value: "doc", ) no value would be there if no selection was made either. Maybe you can try this and hopefully it will help.


/Johan

View solution in original post

1 Reply
Ojjis
Correct answer by
Level 7
Level 7

Hi there,
It looks like (when comparing to other standard widgets that use the CQ.form.Selection) that you have used "changed" instead of "selectionchanged" for the listener. If that was the case that you needed that it would explain why the listener event was not fired. Then no new value would be saved and since you did not specify a default value (like: value: "doc", ) no value would be there if no selection was made either. Maybe you can try this and hopefully it will help.


/Johan

View solution in original post