Note: This filter was deprecated in Gravity Forms [SINCE PLACEHOLDER] and will be removed in Gravity Forms 4.0. Use the gform/merge_tag/field_value filter instead.
Description
The gform_value_merge_tag filter allows developers to override the value a field merge tag returns on the front end, for example when the merge tag is used in a calculation formula.
Usage
The filter name includes the form ID and the field ID. (format: gform_value_merge_tag_FORMID_FIELDID)
gform.addFilter( 'gform_value_merge_tag_1_4', function( value, input, modifier ) {
// Custom logic here.
return value;
} );
Parameters
| Parameter | Type | Description |
|---|---|---|
value | bool | Always false. Return a value to override the merge tag value, or false to keep the default. |
input | object | A jQuery object with the field inputs. |
modifier | string | The merge tag modifier, such as value or label. |
Examples
Return a Date field value as month/day/year.
This example joins the three inputs of a dropdown or text Date field (field 4 on form 1) into a single date. It keeps the default value for the :label modifier.
gform.addFilter( 'gform_value_merge_tag_1_4', function( value, input, modifier ) {
if ( modifier === 'label' ) {
return false;
}
if ( input.length === 1 ) {
return input.val();
}
return jQuery( input[0] ).val() + '/' + jQuery( input[1] ).val() + '/' + jQuery( input[2] ).val();
} );
Placement
Reference the article Adding JavaScript Code to the Frontend of Your Site.
Source Code
This filter is located in js/gravityforms.js.
Since
This filter was added in Gravity Forms 2.4