Vue-form-generator: Problem with inputType="date"

Created on 1 Mar 2017  路  8Comments  路  Source: vue-generators/vue-form-generator

I have problem with field type="input", inputType="date" and inputType="datetime-local"
This fields save date in format: Fri Nov 30 1973 00:00:00 GMT+0100 (CET)
But cannot read such format. I expects number: 123412323232

Fiddle:
https://jsfiddle.net/ebmgv286/3/

bug medium before v2 stable

Most helpful comment

Hot fix: https://jsfiddle.net/icebob/ebmgv286/4/

{
    type: "input",
    inputType: "date",
    label: "Example date",
    model: "exampleDate",
    set: function(model, val) {
        model.exampleDate = new Date(val).valueOf();
    }
}

All 8 comments

Thanks, missing some formatter from field code

Hot fix: https://jsfiddle.net/icebob/ebmgv286/4/

{
    type: "input",
    inputType: "date",
    label: "Example date",
    model: "exampleDate",
    set: function(model, val) {
        model.exampleDate = new Date(val).valueOf();
    }
}

I checked fiddle - now I can save and read dates without errors. Much better :)

Is it possible to save dates in other format? E.g. "2017-03-02 12:04:00"?

If I fixed this bug in vfg then yes.

I fixed it. Fiddle with the fixed bundle: https://jsfiddle.net/ebmgv286/5/

Other example with formatted date value: https://jsfiddle.net/ebmgv286/6/

Does this require any docs changes?

@dflock Maybe. Because now type="input" field have a "format" property if the inputType is date, 藳datetime or datetime-local

Hot fix: https://jsfiddle.net/icebob/ebmgv286/4/

{
  type: "input",
  inputType: "date",
  label: "Example date",
  model: "exampleDate",
  set: function(model, val) {
      model.exampleDate = new Date(val).valueOf();
  }
}

This work for me. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DelfsEngineering picture DelfsEngineering  路  4Comments

reardestani picture reardestani  路  5Comments

jaywilburn picture jaywilburn  路  3Comments

gkurdej picture gkurdej  路  5Comments

ndro picture ndro  路  4Comments