Results 1 to 4 of 4

Thread: How to send empty timefield?

  1. #1
    Sencha User
    Join Date
    May 2013
    Posts
    14
    Answers
    1

    Default How to send empty timefield?

    I'm developing Extjs form and have to send all field, also empty fields. It works for all types of fields only timefield is not send. Here an example with datefield and timefield. Why do they behavior differently? Which config should I use to send empty timefield? Preferred as variable name with empty string as value. Do you have an idea?
    Code:
    Ext.create('Ext.form.Panel', {
    renderTo: Ext.getBody(),
    standardSubmit: true,
    items: [{
        fieldLabel: 'Datefield',
        format: 'Y-m-d',
        name: 'Datefield',
        // value: '2015-01-01',
        xtype: 'datefield'
    },{
        fieldLabel: 'Timefield',
        format: 'H:i:s',
        name: 'Timefield',
        // value: '16:00:00',
        xtype: 'timefield'
    }],
    buttons: [{
        text: 'Submit',
        formBind: true,
        handler: function(){
            this.up('form').getForm().submit({
                url: 'http://yourfavoriteurl',
                standardSubmit: true,
                method: 'POST' // 'GET'
            });
        }
    }] 
    });

  2. #2
    Sencha Premium User
    Join Date
    Mar 2011
    Posts
    287
    Answers
    35

    Default

    In your handler, the following gets you an object with all fields (with/without values):

    Code:
    var values = this.up('form').getForm().getFieldValues();
    The form.submit(...) can take a params attribute likes this using the above:

    Code:
    params : values
    Hope this helps.

  3. #3
    Sencha User
    Join Date
    May 2013
    Posts
    14
    Answers
    1

    Default

    Thank you for your hint, I'll try to build some workaround but it's not clean solution for me.
    I can't still understand why timefield has different logic as all other types.
    Even checkboxfield can send empty content when config uncheckedValue is set.
    Is there a reason for exceptional behaviour of timefield?
    Perhaps this is a bug not feature?

  4. #4
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    707
    Answers
    25

    Default

    Stepping through the debugger in chrome on sencha fiddle with Ext JS 5.1.0.107 :

    For datefield getSubmitValue returns '', Timefield returns null. When null is returned as the value it is not included in the params that are submitted.

    Code:
    Ext.define('Ext.form.field.Date', {
    ...
       getSubmitValue: function() {
            var format = this.submitFormat || this.format, 
            value = this.getValue();
            return value ? Ext.Date.format(value, format) : ''; <----------- '' returned
        },

    Code:
    Ext.define('Ext.form.field.Time', {
    
    ...
        getSubmitValue: function() {
            var me = this, 
            format = me.submitFormat || me.format, 
            value = me.getValue();
            return value ? Ext.Date.format(value, format) : null; <---------- null returned
        },

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •