1. #1
    Sencha User ykey's Avatar
    Join Date
    Mar 2010
    Location
    USA
    Posts
    245
    Vote Rating
    27
    ykey has a spectacular aura about ykey has a spectacular aura about

      0  

    Default Are Cross Field Model Validations Possible?

    Are Cross Field Model Validations Possible?


    I am not seeing a way to validate a field of a model based on the value of another field in the same model. For example ensuring that a start date is before an end date.

    I know that there are examples of this using a form but I want this validation to live in my model. Am I missing something?

  2. #2
    Sencha User
    Join Date
    Apr 2011
    Posts
    3
    Vote Rating
    1
    oaj is on a distinguished road

      0  

    Default I have the same problem

    I have the same problem


    The only way I see is to override Ext.data.Model.validate and pass the model instance to the validation function.

    valid = validators[type](validation, this.get(field), this);

  3. #3
    Ext JS Premium Member christocracy's Avatar
    Join Date
    Oct 2006
    Location
    Montreal
    Posts
    380
    Vote Rating
    0
    christocracy is on a distinguished road

      0  

    Default Validation block

    Validation block


    Seems model validations should accept an optional block called with the record instance. That's what ORMs like ActiveRecord or DataMapper do in Ruby.

    I'd wish it could do this:
    Code:
    Ext.define('User', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'name',     type: 'string'},
            {name: 'age', type: 'int'}
        ],
    
        validations: [{
            field: 'age', 
            handler: function(value, record) {
                return (record.data.name === 'Baz' && record.data.age < 21) ? true : false;
            }
        }]
    });
    Last edited by christocracy; 2 Jun 2011 at 5:25 AM. Reason: make clear, this code does not exist
    /**
    * @author Chris Scott
    * @business www.transistorsoft.com
    * @rate $120USD / hr; training $500USD / day / developer (5 dev min)
    *
    * @SenchaDevs http://senchadevs.com/developers/transistor-software
    * @twitter http://twitter.com/#!/christocracy
    * @github https://github.com/christocracy
    */

  4. #4
    Sencha User
    Join Date
    Apr 2011
    Posts
    3
    Vote Rating
    1
    oaj is on a distinguished road

      1  

    Default


    here you can see how to achieve what you want

    http://oajamfibia.wordpress.com/2011...ion-in-extjs4/

  5. #5
    Sencha User ykey's Avatar
    Join Date
    Mar 2010
    Location
    USA
    Posts
    245
    Vote Rating
    27
    ykey has a spectacular aura about ykey has a spectacular aura about

      0  

    Default


    I was able to do this using oaj's method awhile back. Very surprised this was missed/left out by Sencha.

Similar Threads

  1. Cross icon of search field is not displayed in iphone
    By Shijutv in forum Sencha Touch 1.x: Discussion
    Replies: 4
    Last Post: 3 Feb 2012, 2:17 AM
  2. Cross icon not displayed in search field
    By wdonne in forum Sencha Touch 1.x: Bugs
    Replies: 0
    Last Post: 21 Mar 2011, 2:50 AM
  3. IPv6 field validations??
    By sumitarora in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 25 Sep 2008, 8:20 AM
  4. Simple cross field validation
    By willo in forum Ext 1.x: Help & Discussion
    Replies: 5
    Last Post: 25 Jul 2007, 12:07 AM
  5. Cross field validation
    By jimmyphp in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 19 May 2007, 11:34 AM

Thread Participants: 2

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar