PDA

View Full Version : FieldSet enable/disable



marco.braga
20 Aug 2007, 6:50 AM
Hello,

I've noticed that if I disable() / enable() a fieldset, the widgets included in the set appear as disabled or enabled, but internally they are not disabled [as example, they are validated on form submit]. It seems that the disable and enable methods on fieldsets don't apply recursively to the contained widgets.
Is this normal?

Thx

pianoroy
20 Aug 2007, 10:12 AM
Well, if your validation allows them to be empty, then validating them shouldn't be a problem.

If the user disables them, you can just set them to be empty before disabling, thereby allowing them to pass validation.
I'm pretty sure disabling a field doesn't remove it from the form - it will still be submitted (I might be wrong, though).

marco.braga
22 Aug 2007, 7:15 AM
Hi Pianoroy,

I can confirm that disabled elements aren't checked for validation, so disabled fields can pass validation even if invalid. But this is not a problem.

The problem, from my point of view, is that disabling a FieldSet does not disable the objects it contain, even if they appear visualy disabled (I think it is browser/HTML feature).
But if they are invalid, the form can't be submitted because for Ext they are still enabled but visually, for the user, they appear as disabled.

I think the disabling a FieldSet (Ext object) should also disable all contained Ext objects too.

Netarious
27 Sep 2007, 4:44 AM
I also encountered this problem, except that I was using form layouts rather than fieldsets but this solution should work for you too.

I noticed that disabled items had the class ".x-item-disabled" added to them, so if I check for any parents with that class on the validation event then I can return that item is valid.

Add this to your page:


Ext.override(Ext.form.Field, {
validate: function(){
if(this.el.findParent('.x-item-disabled')){
this.clearInvalid();
return true;
}
if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
this.clearInvalid();
return true;
}
return false;
}
}
);

MrFox
24 Aug 2015, 1:32 AM
Why do you guys start talking about validation? That's not what the question is about.I have the same problem where I enable the fieldset, but visually the fields remain disabled.