2
votes

I am using ExtJS Forms.

My form code is as follows:

Ext.create('Ext.form.Panel', {
    width: 600,
    layout: 'anchor',
    defaultType: 'textfield',
    items: [{
        fieldLabel: "Specimen",
        name: "Specimen"
    }, {
    .
    .
    .
    }, {
        fieldLabel: "Time Stamp",
        name: "timestamp",

        xtype: "timefield",

        allowBlank: false
    }],
    buttons: [{
        text: 'Save',
        handler: function() {

            var form = this.up('form').getForm();

            var fieldValuePair = form.getFieldValues();

        }
    }],
    renderTo: "ui"
});                 

For some special purpose, I want to get the id/value pairs in json format, which I have acheived using the .getFieldValues() function.

The problem is, when I press the "Save" button, the "fieldValuePair" variable in the handler function correctly gets all the values in json format except for the fields that have the "timefield" or "datefield" xtypes.

I have searched the web, but didn't come across any solution.

Any idea what may be the problem...?

1

1 Answers

1
votes

Try with:

handler: function () {
            var form = this.up('form').getForm();
            var formValues = form.getValues(); // instead getFieldValues
            console.log(formValues);
        }

this way it returns:

 date    "12:30 AM"

and not:

 date
Date {Tue Jan 01 2008 00:15:00 GMT+0100 (Central European Standard Time)} // this being another object 

cheers!