Results 1 to 2 of 2

Thread: Simple Form Validation in Modern

  1. #1
    Sencha User nak1's Avatar
    Join Date
    Jan 2008
    Posts
    318
    Answers
    2

    Default Simple Form Validation in Modern

    Guys,

    I used to be able to do simple form validation in the Sencha Touch by creating a model as follows:
    Code:
    Ext.define("Data.model.Base", {
    				extend: "Ext.data.Model", 
    				fields: [{
                            name: 'display_name',
                            type: 'string'
                        },{
                            name: 'typeid',
                            type: 'int'
                        }],
    			  	validators: [
    	                {type: 'presence', 'display_name',message:"Please enter a display name"},
    					{type: 'presence', name:'typeid',message:"Please select a type"}]
    				
    				
    			});
    model =Ext.create('SystemData.model.ResourceInputBase',form.getValues());
    errors = model.getValidation();
    errors.isValid();
    The issue is that errors.isValid is always returning true, even when the display_name is blank

    Is there there something I need to adjust in the model? Or has the process completely been revamped to use a model view? If so is there a tutorial for the modern framework that I can reference?

    Thanks
    No longer a Newbie

  2. #2
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Hi--

    That should work, although you should update your validators like so:

    Code:
    validators: [{
        type: 'presence',
        field: 'display_name', // field instead of name
        message: "Please enter a display name"
    }, {
        type: 'presence',
        field: 'typeid', // field instead of name
        message: "Please select a type"
    }]
    or

    Code:
    validators: {
        display_name: {
            type: 'presence',
            message: "Please enter a display name"
        },
        typeid: {
            type: 'presence',
            message: "Please select a type"
        }
    }
    Thanks!
    Joel

Similar Threads

  1. Simple form validation with Sencha Touch
    By afry in forum Sencha Touch 1.x: Discussion
    Replies: 4
    Last Post: 25 Aug 2014, 12:21 AM
  2. Simple form validation problem
    By bakacza in forum Sencha Touch 2.x: Discussion
    Replies: 1
    Last Post: 17 Jul 2012, 4:08 AM
  3. Proble withi simple form validation
    By senchanew in forum Sencha Touch 2.x: Q&A
    Replies: 4
    Last Post: 20 Jun 2012, 11:41 AM
  4. Simple server-side form validation. how to?
    By webleaf in forum Ext: Discussion
    Replies: 3
    Last Post: 25 Sep 2011, 5:40 AM
  5. simple form validation / tooltip help
    By yattias in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 23 Nov 2009, 6:46 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
  •