Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Retain the value after clicking on submit button in a form #125

Open
sandya112 opened this issue Nov 21, 2023 · 0 comments
Open

Retain the value after clicking on submit button in a form #125

sandya112 opened this issue Nov 21, 2023 · 0 comments

Comments

@sandya112
Copy link

i want the field to retain value after clicking on submit button in form from this :
image

to :
image

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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant