Prefill with today fixes (#87)

This commit is contained in:
Chirag Chhatrala 2023-02-07 18:10:46 +05:30 committed by GitHub
parent 049649a81e
commit 7b5968401b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -94,7 +94,7 @@ export default {
this.compVal = null this.compVal = null
} }
}, },
immediate: true immediate: false
}, },
toDate: { toDate: {
handler(val) { handler(val) {
@ -107,7 +107,7 @@ export default {
this.compVal = null this.compVal = null
} }
}, },
immediate: true immediate: false
} }
}, },

View File

@ -350,9 +350,13 @@ export default {
formData[field.id] = urlPrefill.getAll(field.id + '[]') formData[field.id] = urlPrefill.getAll(field.id + '[]')
} else if (field.type === 'date' && field.prefill_today === true) { // For Prefill with 'today' } else if (field.type === 'date' && field.prefill_today === true) { // For Prefill with 'today'
const dateObj = new Date() const dateObj = new Date()
const currentDate = dateObj.getFullYear() + '-' + let currentDate = dateObj.getFullYear() + '-' +
String(dateObj.getMonth() + 1).padStart(2, '0') + '-' + String(dateObj.getMonth() + 1).padStart(2, '0') + '-' +
String(dateObj.getDate()).padStart(2, '0') String(dateObj.getDate()).padStart(2, '0')
if(field.with_time === true){
currentDate += 'T' + String(dateObj.getHours()).padStart(2, '0') + ':' +
String(dateObj.getMinutes()).padStart(2, '0');
}
formData[field.id] = currentDate formData[field.id] = currentDate
} else { // Default prefill if any } else { // Default prefill if any
formData[field.id] = field.prefill formData[field.id] = field.prefill