PHP Code:
new Ext.form.FormPanel({
defaultType: 'textfield',
items: [new Ext.form.ComboBox({
store: new Ext.data.SimpleStore({
fields: ['val', 'type'],
data: [
['1', 'Test'],
['2', 'Test2 ']
]
}),
displayField: 'type',
fieldLabel: 'Type 1',
name: 'subType',
hiddenName: 'subType',
id: 'subTypeId',
valueField: 'val',
mode: 'local',
editable: false,
triggerAction: 'all',
emptyText: 'Sub Type...',
selectOnFocus: true,
width: 100,
allowBlank: true,
listeners: {
'select': function (combo, record) {
var subTypeId = Ext.getCmp('subTypeId').getValue();
console.log(subTypeId);
Ext.getCmp('type2Id').setValue("");
console.log(Ext.getCmp('type2Id').allowBlank);
if (subTypeId === 2) {
Ext.getCmp('type2Id').allowBlank = true;
Ext.getCmp('type2Id').setDisabled(true);
Ext.getCmp('type2Id').setReadOnly(true);
console.log(Ext.getCmp('type2Id').disabled);
} else {
Ext.getCmp('type2Id').allowBlank = false;
Ext.getCmp('type2Id').setDisabled(false);
Ext.getCmp('type2Id').setReadOnly(false);
}
console.log(Ext.getCmp('type2Id'));
console.log(Ext.getCmp('type2Id').validate());
}
}
}), new Ext.form.ComboBox({
store: new Ext.data.SimpleStore({
fields: ['val', 'type'],
data: [
['1', 'Test'],
['2', 'Test2 ']
]
}),
displayField: 'type',
fieldLabel: 'Type 2',
name: 'subType',
hiddenName: 'subType',
id: 'type2Id',
valueField: 'val',
mode: 'local',
editable: false,
triggerAction: 'all',
emptyText: 'Sub Type...',
selectOnFocus: true,
width: 100,
allowBlank: false
})],
renderTo: Ext.getBody()
});