Skip to content

Commit beafe7b

Browse files
committed
gpnf-sort-nested-form-entries.js: Added support to sort nested form entries.
1 parent 45ab4d6 commit beafe7b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Gravity Perks // Nested Forms // Sort Nested Form Entries
3+
*
4+
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
5+
*
6+
* Instructions:
7+
*
8+
* 1. Install this snippet with our free Custom JavaScript plugin.
9+
* https://gravitywiz.com/gravity-forms-code-chest/
10+
*/
11+
window.gform.addFilter( 'gpnf_sorted_entries', function( entries, formId, fieldId, gpnf ) {
12+
// Replace "3" with the field ID of the field you would like to sort by.
13+
// JavaScript provides several ways to sort arrays, including different sorting functions like localeCompare(), numeric sorting, and custom sorting based on object properties. Use the one that best fits your needs.
14+
return entries.sort((a, b) => a["3"].label.localeCompare(b["3"].label));
15+
}, 10, 'emails' );
16+

0 commit comments

Comments
 (0)