PDA

View Full Version : Dynamically adding multiple panels to a form



nani1216
21 Feb 2012, 4:38 AM
I have 3 panels and each panel will have 7 - 10 fields.The main form panel contains a combo field and the 3 panels.Based on the combo selected value i'm hiding the remaining 2 panels and showing one panel.All these three panels have allowBlank: false validations for the fields.



While submitting the form, the fields which are hidden are also validated and prevents the form from submitting. So i want to disable the fields which are hidden. i'm using this code.



question_multiple_option.query('.component').forEach(function(c){c.setDisabled(true);});


But in EXT 4.X disabled fields are also validated while submitting a form.In Ext 2.X and 3.X disabled fields are not validated and not submitted.



previously i used this code in ext 2.X




Ext.getCmp('option').cascade(function(comp){
if (comp.isFormField) {
//comp.enable();
comp.disable();
}
});

Is it the right way to implement a form with multiple panels by hide and showing the panels. Or how can i add / remove a panel to a form dynamically ?.Is there any better way to implement this kind of form.Thank you.

mitchellsimoens
21 Feb 2012, 6:24 AM
isValid doesn't do any checking of disabled or anything, it simple goes through all the fields and validates it:


isValid: function() {
var me = this,
invalid;
me.batchLayouts(function() {
invalid = me.getFields().filterBy(function(field) {
return !field.validate();
});
});
return invalid.length < 1;
},