Results 1 to 5 of 5

Thread: FieldSet enable/disable

  1. #1
    Ext User
    Join Date
    Jul 2007
    Posts
    26
    Vote Rating
    0
      0  

    Default FieldSet enable/disable

    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

  2. #2
    Sencha Premium Member
    Join Date
    Jun 2007
    Posts
    31
    Vote Rating
    0
      0  

    Default

    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).

  3. #3
    Ext User
    Join Date
    Jul 2007
    Posts
    26
    Vote Rating
    0
      0  

    Default

    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.

  4. #4
    Ext User
    Join Date
    Aug 2007
    Location
    North Somerset, UK
    Posts
    22
    Vote Rating
    0
      0  

    Default

    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:

    Code:
    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;
    	    }
    	}
    );

  5. #5
    Sencha User
    Join Date
    Sep 2014
    Posts
    23
    Vote Rating
    -5
      0  

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •