Thank you for reporting this bug. We will make it our priority to review this report.
  1. #11
    Ext User
    Join Date
    Dec 2007
    Posts
    13
    Vote Rating
    0
    worthy is on a distinguished road

      0  

    Default


    Quote Originally Posted by evant View Post
    The problem is really in the naming. allowBlank implies blank is tolerated but not necessarily a valid value.

    allowBlank was behaving as blankValid.

    I think we need a way to shift the behaviour to have 2 properties

    1) Blank is allowed, but continue with validation
    2) Blank is a valid value
    What do you want to validate if blank is allowed(1)? Against regex or maxLength? I think only this.validate is reasonable.

    Adding another option will be ambiguous cause what will this mean:
    Code:
    this.allowBlank = true;
    this.blankValid = false;
    
    // or
    
    this.allowBlank = false;
    this.blankValid = true;
    allowBlank in my opinion is clear. Blank is allowed or not.

  2. #12
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    94
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    It not only needs to check validate, but also vtype (e.g. for vtype:'password' blank is only valid when the original password is also valid).

    But I agree that adding another config option (blankValid, default true) would be a better (and Ext 2.x compatible) solution:
    Code:
    Ext.override(Ext.form.TextField, {
    	blankValid : true,
    	validateValue : function(value){
    		if(value.length < 1 || value === this.emptyText){ 
    			if(!this.allowBlank){
    				this.markInvalid(this.blankText);
    				return false;
    			}
    			if(this.blankValid){
    				this.clearInvalid();
    				return true;
    			}
    		}
    		if(Ext.isFunction(this.validator)){
    			var msg = this.validator(value);
    			if(msg !== true){
    				this.markInvalid(msg);
    				return false;
    			}
    		}
    		if(this.vtype){
    			var vt = Ext.form.VTypes;
    			if(!vt[this.vtype](value, this)){
    				this.markInvalid(this.vtypeText || vt[this.vtype +'Text']);
    				return false;
    			}
    		}
    		if(this.regex && !this.regex.test(value)){
    			this.markInvalid(this.regexText);
    			return false;
    		}
    		if(value.length < this.minLength){
    			this.markInvalid(String.format(this.minLengthText, this.minLength));
    			return false;
    		}
    		if(value.length > this.maxLength){
    			this.markInvalid(String.format(this.maxLengthText, this.maxLength));
    			return false;
    		}
    		return true;
    	}
    });

  3. #13
    Ext User
    Join Date
    Oct 2007
    Posts
    8
    Vote Rating
    0
    Chimera is on a distinguished road

      0  

    Default


    I really hope that makes it to the next release, because it works like a charm

    Thanks Condor!

  4. #14
    Ext User
    Join Date
    Dec 2007
    Posts
    13
    Vote Rating
    0
    worthy is on a distinguished road

      0  

    Default


    And what with validators precedence?
    Why length is validated after regex? Why we should call this.validate (may be expensive call: dom access, for loops or somethig) if format is wrong?

    So in your proposition if I set:
    Code:
    this.allowBlank = false;
    this.blankValid = true;
    It will mark and then unmark my field? Hm.

    My proposition is 2.2.x compatible. (Tested)
    And any password validator could set and unset the allowBlank flag.

    PS: Where I can find code of vtype:'password'?

  5. #15
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    94
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    I am assuming that almost all fields have either:
    1. a validator function
    2. a vtype
    3. other field settings
    but not a combination of the above.
    This makes the validation order not really relevant.

    Setting allowBlank:false makes the setting of blankValid irrelevant. Blank is always invalid.

    The password and daterange vtypes can be found in examples/form/adv-vtypes.js.

  6. #16
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    6
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    Marking this thread as [DUP] in favor of the more recent thread here:
    http://extjs.com/forum/showthread.ph...822#post335822

    The linked thread also links back to this thread.

  7. #17
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,358
    Vote Rating
    127
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    The behavior has been changed in Ext 3.0 as of revision 4467 (Post RC2) to run the validators in validateValue in the following order:
    validator, allowBlank, minLength, maxLength, vtype then regex

    http://extjs.com/forum/showthread.php?t=69859&p=345729
    Aaron Conran
    @aconran
    Sencha Architect Development Team