Results 1 to 7 of 7

Thread: sending Date object to server via direct form submit

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Sep 2009
    Posts
    31
    Vote Rating
    0
      0  

    Default sending Date object to server via direct form submit

    I have a datefield with a specific format defined like so:
    Code:
                  { xtype: 'datefield', format: 'm/d/Y H:i:s', editable: true, fieldLabel: 'Earliest', bind: '{filters.earliest}' },
    As you can see, I am binding the value of datefield to a view model object. The object is like so:
    Code:
        data: {
            filters: {
                area: '',
                name: '',
                earliest: '',
                latest: '',
                user: ''
            }
    Within the controller, whenever I retrieve the value of this datefield, it returns the Date object itself and not it's string representation in the format I want.

    This is fine if I submit this Date object via a form WITHOUT direct api. i.e. by manually specifying a URL and method=POST.

    But if I submit it via a direct form submit api, it doesn't work because Direct Manager seems to be encoding the Date object weirdly which PHP does not understand.

    What do I do?

  2. #2
    Sencha User
    Join Date
    Sep 2009
    Posts
    31
    Vote Rating
    0
      0  

    Default

    Specifically speaking, when submitting Date object through normal POST form submit, the POST request shows:
    Code:
    • earliest: 2017-11-14T00:00:00
    • latest: 2017-11-01T00:00:00


    • But when submitting the same through 'api: {submit: MyClass.function}' direct api, the POST request shows:
      Code:
      • earliest: Tue Nov 14 2017 00:00:00 GMT-0800 (Pacific Standard Time)
      • latest: Wed Nov 01 2017 00:00:00 GMT-0700 (Pacific Daylight Time)


      • PHP can understand the first format (strtotime), but not the second format.





  3. #3
    Sencha User
    Join Date
    Sep 2009
    Posts
    31
    Vote Rating
    0
      0  

    Default

    Can someone please respond to this? I really want to use Direct API for my form submissions. But I am having to use manual POSTs because of above issue.

  4. #4
    Sencha User
    Join Date
    Apr 2013
    Posts
    838
    Vote Rating
    169
      0  

    Default

    There is submitFormat config you can use.

  5. #5
    Sencha User
    Join Date
    Sep 2009
    Posts
    31
    Vote Rating
    0
      0  

    Default

    submitFormat defaults to 'format' which I have specified as 'm/d/Y H:i'. In any case, I also tried setting submitFormat to the same thing and that did not do anything different.

  6. #6
    Sencha User
    Join Date
    Sep 2009
    Posts
    31
    Vote Rating
    0
      0  

    Default

    The thing is my datefield is not part of a 'form'. It is sitting inside a toolbar in a grid. It is bound to a variable in the view model. Then I have a separate button which opens up a window containing a form. In this form, when I hit the submit button, I collect the values from viewmodel and send them along. Perhaps that is why 'submitFormat' is not taking effect.

  7. #7
    Sencha User
    Join Date
    Sep 2009
    Posts
    31
    Vote Rating
    0
      0  

    Default

    I manually did Ext.Date.format on the viewmodel variable (which is a Date object) before sending it to the form submit call and now it works fine!
    So basically the issue was that my datepicker field was not part of a 'form' panel, so I had to do the formatting myself before submitting.

Similar Threads

  1. Replies: 1
    Last Post: 31 Mar 2013, 7:35 AM
  2. Replies: 1
    Last Post: 17 Dec 2012, 7:45 AM
  3. Replies: 1
    Last Post: 3 Jun 2012, 1:34 PM
  4. Replies: 1
    Last Post: 21 Jan 2012, 10:20 AM

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
  •