Skip to content

Instantly share code, notes, and snippets.

@KZeni
Last active October 20, 2020 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KZeni/519c14f994aeb2a370694ec46904fff5 to your computer and use it in GitHub Desktop.
Save KZeni/519c14f994aeb2a370694ec46904fff5 to your computer and use it in GitHub Desktop.
Gravity Forms - Prevent truncating list of choices on radio & checkbox fields on editor views

gravityforms/includes/fields/class-gf-field-radio.php has:

if ( $is_form_editor && $count >= 5 ) {
	$editor_limited = true;
	break;
}

changed into:

$gf_radio_field_editor_choice_limit = apply_filters( 'gf_radio_field_editor_choice_limit', 5); // Default to 5 being the limit but allow a different value to be specified via filter

if ( $is_form_editor && $count >= $gf_radio_field_editor_choice_limit ) {
	$editor_limited = true;
	break;
}

gravityforms/includes/fields/class-gf-field-checkbox.php has:

$is_admin = $is_entry_detail || $is_form_editor;

if ( $is_admin && rgget('view') != 'entry' && $count >= 5 ) {
	break;
}

changed into:

$is_admin = $is_entry_detail || $is_form_editor;

$gf_checkbox_field_editor_choice_limit = apply_filters( 'gf_checkbox_field_editor_choice_limit', 5); // Default to 5 being the limit but allow a different value to be specified via filter

if ( $is_admin && rgget('view') != 'entry' && $count >= $gf_checkbox_field_editor_choice_limit ) {
	break;
}
function increase_gf_radio_checkbox_field_editor_choice_limit(){
	return 999999;
}
add_filter( 'gf_radio_field_editor_choice_limit', 'increase_gf_radio_checkbox_field_editor_choice_limit' );
add_filter( 'gf_checkbox_field_editor_choice_limit', 'increase_gf_radio_checkbox_field_editor_choice_limit' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment