Using Gravity Forms ‘gform_dropdown_no_results_text’ PHP filter

The gform_dropdown_no_results_text filter allows you to change the default “No Results” placeholder text on Drop Down fields when using the enhanced user interface in Gravity Forms.

Usage

To use this filter, add the following code in your theme’s functions.php file:

add_filter('gform_dropdown_no_results_text', 'set_no_results_text', 10, 2);

To target a specific form, add the form ID after the hook name:

add_filter('gform_dropdown_no_results_text_6', 'set_no_results_text', 10, 2);

Parameters

  • $text (string): The text to be filtered.
  • $form_id (integer): ID of the current form.

More information

See Gravity Forms Docs: gform_dropdown_no_results_text

Examples

Change the no results text

Change the no results text to “No results found” for form ID 185:

add_filter('gform_dropdown_no_results_text_185', 'set_no_results_text', 10, 2);

function set_no_results_text($text, $form_id) {
    return 'No results found';
}

Customize the no results text for all forms

Change the no results text to “Nothing found” for all forms:

add_filter('gform_dropdown_no_results_text', 'set_no_results_text_global', 10, 2);

function set_no_results_text_global($text, $form_id) {
    return 'Nothing found';
}

Customize the no results text for specific forms

Change the no results text to “Not available” for form ID 7:

add_filter('gform_dropdown_no_results_text_7', 'set_no_results_text_specific', 10, 2);

function set_no_results_text_specific($text, $form_id) {
    return 'Not available';
}

Add form ID to the no results text

Include the form ID in the no results text:

add_filter('gform_dropdown_no_results_text', 'set_no_results_text_with_id', 10, 2);

function set_no_results_text_with_id($text, $form_id) {
    return "No results found for form ID {$form_id}";
}

Use different no results texts for multiple forms

Set different no results texts for form ID 3 and 5:

add_filter('gform_dropdown_no_results_text', 'set_no_results_text_multiple_forms', 10, 2);

function set_no_results_text_multiple_forms($text, $form_id) {
    if ($form_id == 3) {
        return 'No matches';
    } elseif ($form_id == 5) {
        return 'Nothing found';
    }
    return $text;
}