Results 1 to 2 of 2

Thread: Ext.form.action.DirectSubmit does not work for my form

  1. #1
    Sencha User impactmedia's Avatar
    Join Date
    Dec 2007
    Location
    Germany
    Posts
    25
    Vote Rating
    0
      0  

    Question Ext.form.action.DirectSubmit does not work for my form

    Hi !

    I wanted to use Ext.form.action.DirectSubmit for my form. When I use the code I posted here the Ext direct action is not submitted. The form is perfoming a standard submit.

    I specified the api in my form and set formHandler to true in my remoting api. The form looks pretty the same thank in the direct form example.

    What did I miss?

    Thank you!

    I have the following REMOTING API configuration:

    Code:
    Ext.ns('Direct.api');
    Direct.api.REMOTING_API = {"url":"\/index.php?direct","type":"remoting","actions":{"IndexController":[{"name":"create","len":1},{"name":"read","len":1},{"name":"update","len":1,"formHandler" : true},{"name":"destroy","len":1},{"name":"test","len":1},{"name":"index","len":1},{"name":"load","len":1}]},"namespace":"Direct.api"};
    Here is my form:
    Code:
    Ext.define('My.view.ImpSchema.Form', {
        extend: 'Ext.form.Panel',
        layout: {
            type: 'anchor'
        },
        anchor: '100%',
        bodyPadding: 10,
        defaults: {anchor: '100%'},
        api: {
            load: Direct.api.IndexController.read,
            submit: Direct.api.IndexController.update
        },
        paramOrder: ['uid', 'foo'],
        initComponent: function() {
            var me = this;
            Ext.applyIf(me, {
    
                items: [
                    {
                        xtype: 'fieldset',
                        layout: {
                            type: 'fit'
                        },
                        title: 'Schema Information',
                        items: [
                            {
                                xtype: 'hiddenfield',
                                name: 'id',
                                fieldLabel: 'Id',
                                anchor: '100%'
                            },
                            {
                                xtype: 'textfield',
                                name: 'name',
                                fieldLabel: 'Name',
                                anchor: '100%'
                            },
                            {
                                xtype: 'textfield',
                                name: 'db_system',
                                fieldLabel: 'Database system',
                                anchor: '100%'
                            },
                            {
                                xtype: 'textfield',
                                name: 'db_host',
                                fieldLabel: 'Database host',
                                anchor: '100%'
                            },
                            {
                                xtype: 'textfield',
                                name: 'db_username',
                                fieldLabel: 'User name',
                                anchor: '100%'
                            },
                            {
                                xtype: 'textfield',
                                inputType: 'password',
                                name: 'db_password',
                                fieldLabel: 'Password',
                                anchor: '100%'
                            },
                            {
                                xtype: 'numberfield',
                                name: 'db_port',
                                fieldLabel: 'Port',
                                anchor: '100%'
                            }
                        ]
                    }
                ],
                dockedItems: [
                    {
                        xtype: 'toolbar',
                        id: 'MySchemaToolbar',
                        dock: 'bottom',
                        items: [
                            {
                                xtype: 'button',
                                iconCls: 'icon-save',
                                text: 'Save',
                                handler: function() {
                                    var record = me.getForm().getValues();
                                    console.log(record);
                                    console.log(me);
    
                                    /* This works
                                    Direct.api.IndexController.update(record, function(result, event) {
                                    console.log(result);
                                    console.log(event);
                                    });
                                    */
    
                                    /* This does not work */
                                    me.getForm().submit({
                                        params: {
                                            foo: 'bar',
                                            uid: 34
                                        }
                                    });
    
                                    var win = me.up('window')
                                    if (Ext.isObject(win)) {
                                        win.hide();
                                    }
                                    
                                }
                            },
                            {
                                xtype: 'button',
                                iconCls: 'icon-cancel',
                                text: 'Cancel',
                                handler: function() {
                                    me.getForm().reset();
                                    var win = me.up('window')
                                    if (Ext.isObject(win)) {
                                        win.hide();
                                    }
                                }
                            }
                        ]
                    }
                ]
    
            });
    
            me.callParent(arguments);
        }
    });

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,411
    Vote Rating
    1290
      0  

    Default

    You need to specify the api within your constructor so that it gets applied when the form is created. The problem is that the two apis are returning undefined because the Direct API hasn't finished loading when this file is executed (Ext.define fires).
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

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
  •