-1

我想将登录表单详细信息存储在数据库中。为此,我编写了以下代码。

在我看来代码

Ext.define('SampleForm.view.LoginForm', {
    extend: 'Ext.form.Panel',
    //id:'loginform',
    requires:[
            'Ext.field.Email',
            'Ext.field.Password'
    ],
    config: {
        fullscreen: true,
        layout:{
            type:'vbox'
        },
        items: [
            {
                xtype: 'fieldset',
                title: 'Login',
        id: 'loginform',
                items: [
                    {
                        xtype:'textfield',
                        label:'Name',
                        name:'name'
                    },
                    {
                        xtype: 'emailfield',
                        name: 'email',
                        label: 'Email'
                    },
                    {
                        xtype: 'passwordfield',
                        name: 'password',
                        label: 'Password'
                    }
                ]
            },
            {
                xtype: 'button',
                width: '30%',
                text: 'Login',
                ui: 'confirm',
        action:'btnSubmitLogin'
            }
        ]
    }
});

在控制器中

Ext.define("SampleForm.controller.LoginForm", {
    extend: "Ext.app.Controller",

    config: {
        view: 'SampleForm.view.LoginForm',
        refs: [
        {
            loginForm: '#loginform',
            Selector: '#loginform'
        }
        ],
        control: {
            'button[action=btnSubmitLogin]': {
                tap: "onSubmitLogin"
            }
        }
    },
    onSubmitLogin: function () {

    alert('Form Submitted successfully');
    console.log("test");
    var values = this.getloginform();
    /* Ext.Ajax.request({
                      url: 'http://www.servername.com/login.php',
                      params: values,

                      success: function(response){
                          var text = response.responseText;
                          Ext.Msg.alert('Success', text);
                     }

                     failure : function(response) {
                           Ext.Msg.alert('Error','Error while submitting the form');
                           console.log(response.responseText);
                     }
              });*/
     form.submit({
           url:"http://localhost/sencha2011/form/login.php"
     });
    },
    launch: function () {
        this.callParent();
        console.log("LoginForm launch");
    },
    init: function () {
        this.callParent();
        console.log("LoginForm init");
    }
});

当我单击提交按钮时,出现警报消息,但值未存储在数据库中。在控制台中我收到此错误,未捕获类型错误:对象 [对象对象] 没有方法“getloginform”。

任何人都可以帮助我如何在数据库中插入值。

4

1 回答 1

1

Javascript is case-sensitive. From Sencha Touch docs:

These getter functions are generated based on the refs you define and always follow the same format - 'get' followed by the capitalized ref name.

To use the getter method for ref, loginForm, and to get the form values use:

var values = this.getLoginForm().getValues();
于 2013-01-18T15:28:03.593 回答