Sunday, 27 July 2014

Adobe AEM/CQ - extjs multifield + compositefield with multiple textfields

Suppose we have a form (name: 'formName') with a multifield as follow:

var multifield = new CQ.form.Multifield {
    fieldLabel : 'Multiple: ',
    orderable : false,
    name : 'multifieldExample',
    fieldConfig : {
        xtype : 'compositefield',
        layout: 'form',
        items : [{
          xtype: 'textfield',
          fieldLabel: 'field1: '
        }, {
          xtype: 'textfield',
          fieldLabel: 'field2: '
        }]
    },
    width: 650
}

Here is how we can retrieve the value of the first instance of field2:

formName.getForm().findField('multifieldExample').findByType('compositefield')[0].items.itemAt[1].getValue();

We can retrieve the items under a component via .items.itemAt[i]


No comments:

Post a Comment