Results 1 to 6 of 6

Thread: Custom data field validator not passing in record, just the value

    You found a bug! We've classified it as EXTJS-18997 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Sep 2015
    Posts
    10
    Vote Rating
    3
      1  

    Default Custom data field validator not passing in record, just the value

    I have created a custom validator for my data field like this:
    Code:
    Ext.define('EcxUtils5.Store.validator.Unique', {
    	extend: 'Ext.data.validator.Validator',
    	alias: 'data.validator.Unique',
    	
    	config: {
            message: 'Is a value that is not unique'
        },
    	
    	validate: function(value, record) {
    		console.log(value); //value
    		console.log(record); //undefined
            return true;
        },
    });
    But the record does not get passed in. I realize that even though https://docs.sencha.com/extjs/5.1/5....ator.Validator suggests it should, this article https://docs.sencha.com/extjs/5.1/5....ta.field.Field says otherwise.

    So my question is, has anyone had any luck with getting the record into the validator without using global variables?

  2. #2
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Vote Rating
    186
      0  

    Default

    Thanks for the report!

    This is a known issue (EXTJS-18997) and a ticket has been opened in our bug tracking software.

    Thanks!
    Joel

  3. #3
    Sencha User
    Join Date
    Sep 2015
    Posts
    10
    Vote Rating
    3
      1  

    Default

    Got it.

    Anyone have a workaround? Right now I do an additional level of validation before I commit the record as a quick workaround. Maybe someone did an override of something

  4. #4
    Sencha Premium Member
    Join Date
    Jan 2011
    Posts
    9
    Vote Rating
    1
      0  

    Default

    It looks like this is also/still an issue with ext js version 6.0.1.

  5. #5
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Vote Rating
    186
      0  

    Default

    Quote Originally Posted by mvdweert View Post
    It looks like this is also/still an issue with ext js version 6.0.1.
    This issue has been resolved for the 6.0.2 release.

    Thanks!
    Joel

  6. #6
    Roberto Lopez's Avatar
    Join Date
    Feb 2016
    Location
    Dallas Texas USA
    Posts
    22
    Vote Rating
    0
      0  

    Default

    Here is the override to solve this issue.

    Code:
    Ext.define('Vantage.override.app.bind.Stub', {
        override: 'Ext.app.bind.Stub',
    
    
        bindValidationField: function (callback, scope) {
            //debugger;
            var parent = this.parent,
                name = this.name,
                lateBound = typeof callback === 'string',
                ret;
            if (parent) {
                ret = parent.bind(function (value) {
                    var field = null;
                    if (value && value.isModel) {
                        field = value.getField(name);
                    }
                    if (lateBound) {
                        //scope[callback](field, null, this);
                        scope[callback](field, value, this);
                    } else {
                        //callback.call(scope, field, null, this);
                        callback.call(scope, field, value, this);
                    }
                });
            }
            return ret || null;
        }
    });

Similar Threads

  1. Passing DataView record data to a menu handler
    By mx_starter in forum Ext: Discussion
    Replies: 1
    Last Post: 23 Dec 2012, 7:11 AM
  2. Replies: 2
    Last Post: 22 Feb 2012, 8:14 AM
  3. How to attach a custom validator to a form field?
    By safewolf in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 17 Mar 2008, 5:34 AM
  4. Ext.Field remote validation (custom validator)
    By corey.gilmore in forum Community Discussion
    Replies: 0
    Last Post: 27 Apr 2007, 9:38 AM

Tags for this Thread

Posting Permissions

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