uploader formdata send date in iso2 format

See https://snippet.webix.com/0u36f8ae

How can I change the code send to the date variable in iso2 format?

Thanks

Comments

  • try to use formData method like this

          formData: function(){
            var values = $$("myform").getValues();
            values.date = values.date && values.date.toISOString();
            webix.message(values.date||"date not selected");
            return values;
          },
    
  • Yes, but i'm searching for a global solution. The content of my form is dynamic. In my opinion this should follow the stringify as when doing a regular ajax post

  • i'm searching for a global solution

    try this hack

    (function (i18n) {
      var dateJSON = function(a) {
        return a.toISOString()
      }
      i18n.parseFormatStr = dateJSON;
      var setLocale = i18n.setLocale;
      i18n.setLocale = function () {
        setLocale.apply(this, arguments);
        i18n.parseFormatStr = dateJSON;
      }
    }(webix.i18n));
    webix.ui.datepicker.$protoWait[0].defaults.stringResult = true;
    

    https://snippet.webix.com/resrit4g

  • Thanks! Hopefully this will be integrated in the webix code.

  • Are there any side-effects in other parts of the code when using this hack?

  • Are there any side-effects in other parts of the code when using this hack?

    I've not seen any.
    but if your Date fields are coming as ISO string from server then you need to replace date parser too.

    (function (i18n) {
      var dateJSON = function(a) {
        return a.toISOString()
      }
      var jsonToDate = function(a){
        if(a)return new Date(a)
      }
      i18n.parseFormatStr = dateJSON;
      i18n.parseFormatDate = jsonToDate;
      var setLocale = i18n.setLocale;
      i18n.setLocale = function () {
        setLocale.apply(this, arguments);
        i18n.parseFormatStr = dateJSON;
        i18n.parseFormatDate = jsonToDate;
      }
    }(webix.i18n));
    webix.ui.datepicker.$protoWait[0].defaults.stringResult = true;
    

    https://snippet.webix.com/41814ahj

  • Thanks!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion