Only show choices in the Search Bar that exist in entries
The Search Bar lists every choice a field has, including choices no entry uses. Pre-Filter Choices narrows a search field’s list to the values that entries hold.
Warning: The list is built from every entry in the form, including entries the View doesn’t show. A View limited by a filter still lists the values of the entries it hides.
To offer only the values of the entries the View shows, with the number of matching entries next to each one, use Live Filters. Live Filters shows its options in a sidebar next to the View, and by default it hides an option that no entry matches.
Enable it in the View editor #
You turn on Pre-Filter Choices field by field.
- Open Search Bar Settings by clicking the gear icon on the Search Bar widget, then click the gear icon beside the field you want to change.

- In the field’s settings, find Pre-Filter Choices and select Only show choices that exist in form entries.

- Click Update to save the View.
Pre-Filter Choices appears on search fields that have a list of choices: Drop Down, Radio Buttons, Checkboxes, and Multi Select fields, and the Entry Creator field. It doesn’t appear on a single input of a larger field, such as an Address field’s Country, even when the Search Bar shows that input as a dropdown.
A choice stays in the list when its label or its value matches a value that an entry holds.
Lookup fields from Gravity Forms Dynamic Lookup #
A Lookup field from Gravity Forms Dynamic Lookup stores no list of choices of its own, so its search field doesn’t offer Pre-Filter Choices. For a Lookup field whose Source of Choices is Gravity Forms, this code gives its search field the Lookup’s list of choices, and the setting then appears:
/**
* Gives Dynamic Lookup fields their list of choices in the Search Bar,
* so their search fields offer the Pre-Filter Choices setting.
*
* @param array $choices The search field's choices.
* @param GF_Field|null $field The Gravity Forms field.
*
* @return array The search field's choices.
*/
add_filter( 'gk/gravityview/search/field/choices', function ( $choices, $field ) {
if ( [] !== $choices || ! $field || 'lookup' !== $field->type ) {
return $choices;
}
if ( ! class_exists( '\GravityKit\Lookup\Field' ) ) {
return $choices;
}
// The View editor can pass the Lookup field as a plain Gravity Forms field.
$lookup = $field instanceof \GravityKit\Lookup\Field
? $field
: new \GravityKit\Lookup\Field( $field );
// true lists every choice, without the field's Filter by Field condition.
return $lookup->get_lookup_choices( true );
}, 10, 2 );Note: Adding custom PHP code snippets to your website explains where to add this code.
With the code in place, open the Lookup’s search field settings and turn on Pre-Filter Choices as above. The Search Bar then lists only the choices that entries hold, with Storage Format set to ID (Default) or Text. The code uses the gk/gravityview/search/field/choices filter.
Enable it with a filter (advanced) #
To turn on Pre-Filter Choices for every search field with choices on the site, add this code:
add_filter( 'gravityview/search/sieve_choices', '__return_true' );To turn it on for one field in one View, check the View ID and the field ID. This example turns it on for field 6 in View 4:
/**
* Turns on Pre-Filter Choices for field 6 in View 4.
*
* @param bool $sieve Whether to pre-filter the choices.
* @param GF_Field|null $field The Gravity Forms field behind the search field,
* or null for fields such as Entry Creator.
* @param object $context The View's template context.
*
* @return bool Whether to pre-filter the choices.
*/
add_filter( 'gravityview/search/sieve_choices', function ( $sieve, $field, $context ) {
if ( 4 === $context->view->ID && $field && 6 === (int) $field->id ) {
return true;
}
return $sieve;
}, 10, 3 );Note: Adding custom PHP code snippets to your website explains where to add this code.