gpnf_sorted_entries (JS)
Description
Filter to sort entries in the summary.
Usage
window.gform.addFilter( 'gpnf_sorted_entries', 'my_custom_function' );
Parameters
entries array
The entries to sort.
formId int
The parent form ID.
fieldId int
The field ID of the Nested Form field.
gpnf object
The current instance of the GPNestedForms object.
Examples
Sort using a specific field
/**
* WARNING! THIS SNIPPET IS DEPRECATED.
* Unified JS and PHP snippet is available here: https://gravitywiz.com/snippet-library/gpnf-sort-nested-form-entries/
*/
/**
* Gravity Perks // Nested Forms // Sort Nested Form Entries
*
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
* https://gravitywiz.com/gravity-forms-code-chest/
*/
// Change this value to the field ID of the child form you want to sort by.
const sortByFieldId = "3";
window.gform.addFilter('gpnf_sorted_entries', function (entries, formId, fieldId, gpnf) {
// Check if entries exist and have the specified field.
if ( !entries || !entries.length || !entries[0][sortByFieldId]) {
console.warn(`GPNF Sort: Field ID ${sortByFieldId} not found in entries or entries are empty. Returning unsorted entries.`);
return entries;
}
// Sort entries by the specified field's label.
return entries.sort((a, b) => {
if ( !a[sortByFieldId] || !a[sortByFieldId].label) return 1;
if ( !b[sortByFieldId] || !b[sortByFieldId].label) return -1;
return a[sortByFieldId].label.localeCompare(b[sortByFieldId].label);
});
});
Since
This filter is available since Gravity Forms Nested Forms 1.2.7.
All Connections
All Perks
- GF Address Autocomplete
- GF Advanced Calculations
- GF Advanced Phone Field
- GF Advanced Save & Continue
- GF Advanced Select
- GF Auto List Field
- GF Auto Login
- GF Better User Activation
- GF Blocklist
- GF Bookings
- GF Conditional Logic Dates
- GF Conditional Pricing
- GF Copy Cat
- GF Date Time Calculator
- GF Disable Entry Creation
- GF Easy Passthrough
- GF eCommerce Fields
- GF Email Users
- GF Email Validator
- GF Entry Blocks
- GF Expand Textareas
- GF File Renamer
- GF File Upload Pro
- GF Inventory
- GF Limit Checkboxes
- GF Limit Dates
- GF Limit Submissions
- GF Live Preview
- GF Media Library
- GF Multi-Page Navigation
- GF Nested Forms
- GF Notification Scheduler
- GF Page Transitions
- GF Pay Per Word
- GF Populate Anything
- GF Post Content Merge Tags
- GF Preview Submission
- GF Price Range
- GF QR Code
- GF Randomizer
- GF Read Only
- GF Reload Form
- GF Submit to Access
- GF Terms Of Service
- GF Unique ID
- GF Word Count