1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    14
    Vote Rating
    0
    divya_singh is on a distinguished road

      0  

    Default Unanswered: Getting blank values on getValues()

    Unanswered: Getting blank values on getValues()


    I am trying to pass some values as parameters to a rest service. I have entered some value in the form but when I am trying to get the values. I am getting the empty values. attached is the code for reference.
    This is the view code:
    Ext.define('app.view.contact', {
    extend: 'Ext.form.Panel',
    xtype: 'contact1',
    id: 'contactForm',
    config: {

    items:[{
    xtype : 'fieldset',
    title : 'Enter Contact Information:',
    instructions: 'All fields are required',
    layout: {
    type: 'vbox'
    },
    items:[
    {
    xtype: 'textfield',
    name: 'name',
    id:'name',
    label: 'Name',
    placeHolder: 'First Last',
    required: true,
    useClearIcon: true,
    },{
    xtype: 'emailfield',
    name: 'password',
    id:'password',
    label: 'Email',
    placeHolder: 'user@example.com',
    required: true,
    useClearIcon: true,
    },{
    xtype: 'textfield',
    name: 'subject_contact',
    label: 'Subject',
    placeHolder: 'Subject',
    required: true,
    useClearIcon: true,
    },{
    xtype: 'textareafield',
    name: 'message_contact',
    label: 'Message',
    placeHolder: 'Message',
    required: true,
    useClearIcon: true,
    }
    ],
    }
    ,{
    xtype: 'button',
    text: 'Send Message',
    ui:'confirm',
    id:'sendMessage',
    action: 'sendMessage'
    }
    ]
    },
    initialize: function() {
    this.callParent(arguments);
    console.log('contactView:initialize');
    },
    });

    and the controller code is :
    Ext.define('app.controller.mainController', {
    extend: 'Ext.app.Controller',

    views: ['Viewport','home', 'contact'],
    //models:['mainModel'], if you wanted to load a model
    //stores: ['mainStore'], if you wanted to load a store
    refs: [
    {
    ref: 'contactForm',
    selector: '#contactForm'
    }
    ],
    init: function() {
    console.log('mainController:init');

    this.control({
    'button[action=sendMessage]': {
    tap: 'submitContactForm'
    }
    });
    },
    submitContactForm:function(){
    var formValues = this.getContactForm().getValues();
    console.log("NAME"+formValues.name);
    console.log("Password"+formValues.password);

    I am getting the values for Name and Password as blank.
    Can you please let me know if I am doing some mistake.

    Thanks

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Have you looked at the formValues variable by itself and expanded the object? Are all the fields in there? Also, what ST2 version are you using?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    14
    Vote Rating
    0
    divya_singh is on a distinguished road

      0  

    Default


    Hi,
    I am using Sencha Touch 2.0.
    I have a form with two fields name and password. If I am giving the default values for the fields as shown, I am getting the values for name and password through form.getValues().name and form.getValues().password
    {
    xtype: 'textfield',
    id:'name',
    name:'name',
    label: 'Name',
    required: true,
    value:'ABC',
    },{
    xtype: 'emailfield',
    name:'password',
    id:'password',
    label: 'Email',
    required: true,
    value:'password',
    }

    but if I am entering some data into the form and want to get the value of data entered I am getting blank when I print form.getValues().name and form.getValues().password. Can you please let me know what I am doing wrong so that I am not getting the value of information entered.

Thread Participants: 1