Skip to content

Commit cf2f577

Browse files
author
Lionel Bijaoui
committed
format date related fields values
1 parent 323968e commit cf2f577

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/fields/fieldInput.vue

+29-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,35 @@
3737
import abstractField from "./abstractField";
3838
3939
export default {
40-
mixins: [ abstractField ]
40+
mixins: [ abstractField ],
41+
methods: {
42+
formatValueToField(value) {
43+
switch(this.schema.inputType){
44+
case "date":
45+
return moment(value).format("YYYY-MM-DD");
46+
case "datetime":
47+
return moment(value).format();
48+
case "datetime-local":
49+
return moment(value).format("YYYY-MM-DDTHH:mm:ss");
50+
default:
51+
return value;
52+
}
53+
},
54+
formatValueToModel(value) {
55+
console.log(this.schema.inputType, typeof value);
56+
if (value != null) {
57+
if (this.schema.inputType === "date" ||
58+
this.schema.inputType === "datetime" ||
59+
this.schema.inputType === "datetimelocal") {
60+
return new Date(value).getTime();
61+
}else{
62+
return value;
63+
}
64+
} else {
65+
return value;
66+
}
67+
}
68+
}
4169
};
4270
4371
</script>

0 commit comments

Comments
 (0)