gfic_choice_html
Description
This Javascript filter can be used to override the Image Choices HTML on the front-end form display
Usage
Applies to all fields.
gform.addFilter( 'gfic_choice_html', function( html, fieldLabel, priceLabel, selectedPrice, price, formId, fieldId, index ){
return html;
}, 10, 8);
Applies to all fields in a specific form. In this case, form id 5.
gform.addFilter( 'gfic_choice_html_5', function( html, fieldLabel, priceLabel, selectedPrice, price, formId, fieldId, index ){
return html;
}, 10, 8);
Applies to specific field and form. In this case, field id 3 in form id 5.
gform.addFilter( 'gfic_choice_html_5_3', function( html, fieldLabel, priceLabel, selectedPrice, price, formId, fieldId, index ){
return html;
}, 10, 8);
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_html_5_3_0', function( html, fieldLabel, priceLabel, selectedPrice, price, formId, fieldId, index ){
return html;
}, 10, 8);
Parameters
html
String
Current choice HTML.fieldLabel
String
The option label without the price.
Note if you’re using thegfic_choice_text
filter, it will be the filtered value.priceLabel
String
The price text without the field label.
Note if you’re using thegfic_choice_price
filter, it will be the filtered value.selectedPrice
Number
The price of the currently selected option.price
Number
The price of this option. (The option that this HTML 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 Image Choices on a specific field:
gform.addFilter( 'gfic_choice_html_5_3', function( html, fieldLabel, priceLabel, selectedPrice, price, formId, fieldId, index ){
return html + '<div class="my-custom-div"><span>NEW</span></div>';
}, 10, 8);
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.