1. #1

    Join Date
    Nov 2012
    Posts
    15
    Vote Rating
    0
    tmdonalds is on a distinguished road

      0  

    Default Unanswered: Ext Js 4 Has Many Association form submit values

    Unanswered: Ext Js 4 Has Many Association form submit values


    Need help with accessing has many association fields after form submission. Lets get to the code:
    Code:
    xtype:'container',
    
                            flex: 1,                        itemId: 'guestContainer',                        layout: {                            type: 'column'                        },                        items: [                            {                                xtype: 'fieldcontainer',                                columnWidth: 0.83,                                itemId: 'nameContainer0',                                layout: {                                    align: 'stretch',                                    type: 'hbox'                                },                                items: [                                    {                                        xtype: 'textfield',                                        flex: 1,                                        cls: 'field-cls',                                        fieldLabel: 'First Name',                                        labelAlign: 'top',                                        name: 'guest[0].firstName'                                    },                                    {                                        xtype: 'textfield',                                        flex: 0.5,                                        cls: 'field-cls',                                        fieldLabel: 'Middle Initial',                                        labelAlign: 'top',                                        name: 'guest[0].middleInitial'                                    },                                    {                                        xtype: 'textfield',                                        flex: 1,                                        fieldLabel: 'Last Name',                                        labelAlign: 'top',                                        name: 'guest[0].lastName'                                    },                                    {                                        xtype: 'textfield',                                        flex: 1,                                        hidden: true,                                        fieldLabel: 'Label',                                        name: 'guest[0].id'                                    }                                ]                            },                            {                                xtype: 'checkboxfield',                                columnWidth: 0.17,                                itemId: 'chkAddSpouse',                                margin: '17 0 0 5',                                labelAlign: 'top',                                name: 'addSpouse',                                boxLabel: 'Add Spouse'                            }                        ]                    },                    {                        xtype: 'container',                        flex: 1,                        cls: 'topContainerSpacer',                        itemId: 'spouseContainer',                        layout: {                            type: 'column'                        },                        items: [                            {                                xtype: 'fieldcontainer',                                columnWidth: 0.83,                                itemId: 'nameContainer1',                                layout: {                                    align: 'stretch',                                    type: 'hbox'                                },                                items: [                                    {                                        xtype: 'textfield',                                        flex: 1,                                        cls: 'field-cls',                                        fieldLabel: 'First Name',                                        labelAlign: 'top',                                        name: 'guest[1].firstName'                                    },                                    {                                        xtype: 'textfield',                                        flex: 0.5,                                        cls: 'field-cls',                                        fieldLabel: 'Middle Initial',                                        labelAlign: 'top',                                        name: 'guest[1].middleInitial'                                    },                                    {                                        xtype: 'textfield',                                        flex: 1,                                        fieldLabel: 'Last Name',                                        labelAlign: 'top',                                        name: 'guest[1].lastName'                                    },                                    {                                        xtype: 'textfield',                                        flex: 1,                                        hidden: true,                                        fieldLabel: 'Label',                                        name: 'guest[1].id'                                    }                                ]                            },                            {                                xtype: 'button',                                columnWidth: 0.17,                                margin: '20 0 0 5',                                text: 'Remove'                            } ]

    That is how I define my fields for a guest and their spouse. When I want to access the values after submission I get an Uncaught TypeError: Cannot read property '0' of undefined. The value is there but it is having a hard time treating the string as an array. Just to print out the value I am using
    Code:
    
    
    Code:
    var values = form.getValues();
    console.log(values.guest[0].firstName);
    


    Any help is greatly appreciated.

  2. #2

    Join Date
    Nov 2012
    Posts
    15
    Vote Rating
    0
    tmdonalds is on a distinguished road

      0  

    Default Ext Js 4 Has Many Association Get Form Values

    Ext Js 4 Has Many Association Get Form Values


    Couldn't delete previous POST.
    Need help with accessing has many association fields after form submission. Lets get to the code:
    Code:
    items: [
                            {
                                xtype: 'container',
                                flex: 1,
                                itemId: 'guestContainer',
                                layout: {
                                    type: 'column'
                                },
                                items: [
                                    {
                                        xtype: 'fieldcontainer',
                                        columnWidth: 0.83,
                                        itemId: 'nameContainer0',
                                        layout: {
                                            align: 'stretch',
                                            type: 'hbox'
                                        },
                                        items: [
                                            {
                                                xtype: 'textfield',
                                                flex: 1,
                                                cls: 'field-cls',
                                                fieldLabel: 'First Name',
                                                labelAlign: 'top',
                                                name: 'guest[0].firstName'
                                            },
                                            {
                                                xtype: 'textfield',
                                                flex: 0.5,
                                                cls: 'field-cls',
                                                fieldLabel: 'Middle Initial',
                                                labelAlign: 'top',
                                                name: 'guest[0].middleInitial'
                                            },
                                            {
                                                xtype: 'textfield',
                                                flex: 1,
                                                fieldLabel: 'Last Name',
                                                labelAlign: 'top',
                                                name: 'guest[0].lastName'
                                            },
                                            {
                                                xtype: 'textfield',
                                                flex: 1,
                                                hidden: true,
                                                fieldLabel: 'Label',
                                                name: 'guest[0].id'
                                            }
                                        ]
                                    },
                                    {
                                        xtype: 'checkboxfield',
                                        columnWidth: 0.17,
                                        itemId: 'chkAddSpouse',
                                        margin: '17 0 0 5',
                                        labelAlign: 'top',
                                        name: 'addSpouse',
                                        boxLabel: 'Add Spouse'
                                    }
                                ]
                            },
                            {
                                xtype: 'container',
                                flex: 1,
                                cls: 'topContainerSpacer',
                                itemId: 'spouseContainer',
                                layout: {
                                    type: 'column'
                                },
                                items: [
                                    {
                                        xtype: 'fieldcontainer',
                                        columnWidth: 0.83,
                                        itemId: 'nameContainer1',
                                        layout: {
                                            align: 'stretch',
                                            type: 'hbox'
                                        },
                                        items: [
                                            {
                                                xtype: 'textfield',
                                                flex: 1,
                                                cls: 'field-cls',
                                                fieldLabel: 'First Name',
                                                labelAlign: 'top',
                                                name: 'guest[1].firstName'
                                            },
                                            {
                                                xtype: 'textfield',
                                                flex: 0.5,
                                                cls: 'field-cls',
                                                fieldLabel: 'Middle Initial',
                                                labelAlign: 'top',
                                                name: 'guest[1].middleInitial'
                                            },
                                            {
                                                xtype: 'textfield',
                                                flex: 1,
                                                fieldLabel: 'Last Name',
                                                labelAlign: 'top',
                                                name: 'guest[1].lastName'
                                            },
                                            {
                                                xtype: 'textfield',
                                                flex: 1,
                                                hidden: true,
                                                fieldLabel: 'Label',
                                                name: 'guest[1].id'
                                            }
                                        ]
                                    },
                                    {
                                        xtype: 'button',
                                        columnWidth: 0.17,
                                        margin: '20 0 0 5',
                                        text: 'Remove'
                                    }
                                ]
                            }
    That is how I define my fields for a guest and their spouse. When I want to access the values after submission I get an Uncaught TypeError: Cannot read property '0' of undefined. The value is there but it is having a hard time treating the string as an array. Just to print out the value I am using
    Code:
    var values = form.getValues();
    console.log(values.guest[0].firstName);
    Any help is greatly appreciated.