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
htmlString
Current choice HTML.fieldLabelString
The option label without the price.
Note if you’re using thegfic_choice_textfilter, it will be the filtered value.priceLabelString
The price text without the field label.
Note if you’re using thegfic_choice_pricefilter, it will be the filtered value.selectedPriceNumber
The price of the currently selected option.priceNumber
The price of this option. (The option that this HTML applies to).formIdNumber
The current form id.fieldIdNumber
The current field id.indexNumber
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.