From ed7fef7dd7ab2f3e7965029f073365a97394093d Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Fri, 17 Apr 2026 15:15:15 +0200 Subject: [PATCH] Bug 42292: (follow-up) Replace removed dateformat_pref var in OPAC calendar.inc The OPAC port moved the dateformat pref into Koha.addPrefs and dropped the local `var dateformat_pref = ...;` declaration, but four usages of `dateformat_pref` remain in the same file (the debug alert, two `switch` statements, and the get_dateformat_str call in validate_date). At runtime the switches throw ReferenceError, so flatpickr ends up with the default 'Y-m-d' format and date validation via validate_date crashes before showing the invalid-date alert. Replace all remaining occurrences with Koha.prefs.dateformat, which is populated by the new addPrefs block at the top of the include. To test: - Set dateformat syspref to each of us / metric / dmydot / iso. - Open any OPAC page using a flatpickr input (e.g. hold date, patron dob on the registration form). - Confirm the widget renders dates in the expected format and entering an invalid string triggers the validate_date alert. - No ReferenceError in the browser console on page load. Signed-off-by: Paul Derscheid Signed-off-by: Jan Kissig Signed-off-by: Pedro Amorim --- koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc index c07988c65c..8bc1e6a048 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc @@ -21,7 +21,7 @@ }; var sentmsg = 0; if (debug > 1) { - alert("dateformat: " + dateformat_pref + "\ndebug is on (level " + debug + ")"); + alert("dateformat: " + Koha.prefs.dateformat + "\ndebug is on (level " + debug + ")"); } var calendarFirstDayOfWeek = Koha.prefs.CalendarFirstDayOfWeek; var flatpickr_timeformat_string = Koha.prefs.TimeFormat == "12hr" ? "G:i K" : "H:i"; @@ -29,7 +29,7 @@ var flatpickr_dateformat_string = ""; var delimiter = ""; var altinput_dateformat = ""; - switch (dateformat_pref) { + switch (Koha.prefs.dateformat) { case "us": flatpickr_dateformat_string = "m/d/Y"; altinput_dateformat = "mm/dd/yyyy";