Retain the value after clicking on submit button in a form
sandya112 opened this issue · 0 comments
sandya112 commented
i want the field to retain value after clicking on submit button in form from this :
I have done this however it it not retaining value after clicking on submit button :
<duet-date-picker identifier="date" th:identifier="${date}"
th:field="*{date}"
th:value="*{__${searchForm.date}__}">
</duet-date-picker>
<script>
const picker = document.querySelector("duet-date-picker")
const DATE_FORMAT_US = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/
picker.dateAdapter = {
parse(value = "", createDate) {
const matches = value.match(DATE_FORMAT_US)
if (matches) {
return createDate(matches[3], matches[1], matches[2])
}
},
format(date) {
return `${date.getDate()}/${date.getMonth() + 1}/${date.getFullYear()}`
},
}
picker.localization = {
buttonLabel: "Choose date",
placeholder: "dd/mm/yyyy",
selectedDateMessage: "Selected date is",
prevMonthLabel: "Previous month",
nextMonthLabel: "Next month",
monthSelectLabel: "Month",
yearSelectLabel: "Year",
closeLabel: "Close window",
calendarHeading: "Choose a date",
dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
locale: "en-US",
}
</script>