Just a quick follow up on this with my solution in case anybody else comes across this thread:
Background: The data I have is two multidimensional arrays, one holding a series of times and the other boolean values that indicate if an event is sold out at a particular time, e.g.:
times = [[12:00,13:00],[12:00],[17:00,18:00]]
soldOut = [[true,false],[false],[true,false]]
Each set of times is representative of a single day (the arrays above are three day's worth of data).
The user has the ability to add new dates and new times to the repo via another dialog. The problem I had was to create a dynamic dialog that could have x number of checkboxes for the varying number of boolean values in the soldOut array. In the example above, I would need five checkboxes, but if a new time was added then I would need six, etc...
I ended up using a custom xtype to create the varying number of checkboxes:
for(var i=0; i<this.soldOutArray.length; i++) { for(var j=0; j<this.soldOutArray[i].length; j++) { var clsNum = 'customwidget-' + (i+1); var onOff = null; if(this.soldOutArray[i][j] == "true") { onOff = true; } else { onOff = false; } window["soldOut" + i] = new CQ.Ext.form.Checkbox({ cls: clsNum, boxLabel: this.timesArray[i][j], checked: onOff, listeners: { change: { scope: this, fn: this.updateHidden }, check: { scope: this, fn: this.updateHidden } } }); this.add(window["soldOut" + i]); } }This code is from the declaration of the custom xtype and features a pair of nested loops iterating over the values in the sold out array. The default value for the checkboxes is set by the value from the array.
This presents the user with checkboxes for each of the times that have been added and can be toggled on and off to indicate if the time has sold out.
To save the data back to the repo, I have a beforesubmit listener on the dialog:
function saveSoldOutArray(dialog) { //I want to save the data to a different node in the repo var soldOutField = dialog.getField('../../../../jcr:soldOut'), datesPanel = dialog.getField('./soldOutMultiField'), datesSubpanels = datesPanel.findByType('SoldOutMultiField'), items = datesSubpanels[0].items.items; for(var i=0; i<items.length; i++) { //Repopulate the sold out array with the new values of the checkboxes } soldOutField.setValue(JSON.stringify(soldOutArray)); }