gfic_choice_text
Description
This Javascript filter can be used to override the Image Choices label text on the front-end form display
Usage
Applies to all fields.
gform.addFilter( 'gfic_choice_text', function( text, selectedPrice, price, formId, fieldId, index ){
return text;
}, 10, 6);
Applies to all fields in a specific form. In this case, form id 5.
gform.addFilter( 'gfic_choice_text_5', function( text, selectedPrice, price, formId, fieldId, index ){
return text;
}, 10, 6);
Applies to specific field and form. In this case, field id 3 in form id 5.
gform.addFilter( 'gfic_choice_text_5_3', function( text, selectedPrice, price, formId, fieldId, index ){
return text;
}, 10, 6);
Applies to specific choice, field and form. In this case, the first choice (zero-indexed) for field id 3 in form id 5.
gform.addFilter( 'gfic_choice_text_5_3_0', function( text, selectedPrice, price, formId, fieldId, index ){
return text;
}, 10, 6);
Parameters
text
String
Current option label text without the price.selectedPrice
Number
The price of the currently selected option.price
Number
The price of this option. (The option that this label applies to).formId
Number
The current form id.fieldId
Number
The current field id.index
Number
The current option index.
Examples
This example adds some additional HTML to the label on a specific field:
gform.addFilter( 'gfic_choice_text_5_3', function( text, selectedPrice, price, formId, fieldId, index ){
return text + ' <span class="new-style">NEW</span>';
}, 10, 6);
Placement
Your code snippet can be placed in a HTML field on your form (within <script></script>
tags), or in a theme custom JavaScript file, or you could use the free Gravity Forms Code Chest addon by our friends at GravityWiz.
Source Code
This filter is located in the imageChoices.gform_format_option_label
function in js/gf_image_choices.js.