Skip to content

Commit 177fa3c

Browse files
authored
gpnf-sort-nested-form-entries.php: Fixed date field sorting for European formats.
1 parent e38ae40 commit 177fa3c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gp-nested-forms/gpnf-sort-nested-form-entries.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,14 @@ public function output_script() {
115115
}
116116

117117
return entries.sort((a, b) => {
118-
let valA = a[sortFieldId]?.label || '';
119-
let valB = b[sortFieldId]?.label || '';
118+
let valA, valB;
119+
if (isDateField) {
120+
valA = a[sortFieldId]?.value || '';
121+
valB = b[sortFieldId]?.value || '';
122+
} else {
123+
valA = a[sortFieldId]?.label || '';
124+
valB = b[sortFieldId]?.label || '';
125+
}
120126

121127
if (isDateField) {
122128
const dateA = new Date(valA);

0 commit comments

Comments
 (0)