Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

No branches or pull requests

1 participant