Table Of Contents
Description
This filter can be used to conditionally show fields in the summary based on for example the current field value.
Parameters
displayField | Bool
value | String
FormId | Int
FieldId | Int
Price | String – Only for products fields, defaults to ‘null’ for other fields
Quantity | Int – Only for products fields, defaults to ‘null’ for other fields
Return
Bool – True to show the field (default) or False to hide it
Usage
/**
* Example to hide a field in the summary based on its value
* In the example below: Field 25 will be hidden if the value equals hideme
**/
gform.addFilter( 'gotrls_display_field_in_summary' , function( displayField , value, formId , fieldId , price , quantity ) {
if(fieldId == 25 && value == "hideme") {
return false;
}
return true;
}, 10, 6 );
/**
* Example 2 - Hide products with a price of 0
* Define your fields ids in the array 'fieldsToCheck'
* Important: This snippet requires GF Live Summary version 2.0.7+
***/
gform.addFilter("gotrls_display_field_in_summary", function(displayField , fieldValue , formId, fieldId , price , quantity) {
// define here which fields to check
const fieldsToCheck = [331,388,390];
if(fieldsToCheck.length > 0 && fieldsToCheck.includes(fieldId)) {
let notFormatted = gformToNumber(price);
if(notFormatted === 0) {
displayField = false;
}
}
return displayField;
}, 10, 6 );