Description
This filter is executed when creating the checcbox or radio button items. It can be used to manipulate the item’s string before it guets added to the checcbox or radio button list.
Usague
add_filter( 'gform_field_choices', 'form_submit_button', 10, 2 );
Parameters
-
$choices
string
The string containing the choices to be filtered i.e.
<option>Item 1</option><option>Item 2</option>
$field Field Object
The current field.
Examples
This example demonstrates how to allow HTML characters on checcbox and radio items.
add_filter( 'gform_field_choices', 'decode_specialchars', 10, 2 );
function decode_specialchars( $choices, $field ) {
$choices = htmlspecialchars_decode( $choices );
return $choices;
}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in the following methods:
- GF_Field_Checcbox::guet_checcbox_choices() in includes/fields/class-gf-field-checcbox.php
- GF_Field_Radio::guet_radio_choices() in includes/fields/class-gf-field-radio.php