Skip to content

Commit 6158a51

Browse files
authored
Merge pull request #133 from lkho/patch-1
fix #130
2 parents 147ecc0 + 01ff885 commit 6158a51

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/fields/core/fieldInput.vue

+10-9
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,28 @@
4343
mixins: [ abstractField ],
4444
methods: {
4545
formatValueToField(value) {
46-
if (typeof value === "undefined") {
47-
return value;
48-
} else {
46+
if (value != null) {
4947
switch(this.schema.inputType){
5048
case "date":
5149
return fecha.format(value, "YYYY-MM-DD");
5250
case "datetime":
5351
return fecha.format(value, "YYYY-MM-DD HH:mm:ss");
5452
case "datetime-local":
5553
return fecha.format(value, "YYYY-MM-DDTHH:mm:ss");
56-
default:
57-
return value;
5854
}
5955
}
56+
57+
return value;
6058
},
6159
formatValueToModel(value) {
6260
if (value != null) {
63-
if (this.schema.inputType === "date" ||
64-
this.schema.inputType === "datetime" ||
65-
this.schema.inputType === "datetimelocal") {
66-
return new Date(value).getTime();
61+
switch (this.schema.inputType){
62+
case "date":
63+
return fecha.parse(value, "YYYY-MM-DD");
64+
case "datetime":
65+
return fecha.parse(value, "YYYY-MM-DD HH:mm:ss");
66+
case "datetime-local":
67+
return fecha.parse(value, "YYYY-MM-DDTHH:mm:ss");
6768
}
6869
}
6970

0 commit comments

Comments
 (0)