Using Gravity Forms ‘gform_multiselect_placeholder’ PHP filter

The gform_multiselect_placeholder is a Gravity Forms PHP filter that allows you to change the default “Click to select…” placeholder text on Multi Select fields using the enhanced user interface.

Usage

add_filter('gform_multiselect_placeholder', 'your_function_name', 10, 2);

To target a specific form, append the form id to the hook name:

add_filter('gform_multiselect_placeholder_6', 'your_function_name', 10, 2);

From version 1.9.13.19, you can also target a specific field by appending both the form id and the field id to the hook name:

add_filter('gform_multiselect_placeholder_6_3', 'your_function_name', 10, 2);

Parameters

  • $placeholder (string) – The placeholder to be filtered.
  • $form_id (integer) – ID of the current form.
  • $field (Field Object) – The field currently being rendered. Available from version 1.9.13.19.

More information

See Gravity Forms Docs: gform_multiselect_placeholder

Examples

Change placeholder text

Change the placeholder text to “Click to select your options…”:

add_filter('gform_multiselect_placeholder_185', 'set_multiselect_placeholder', 10, 2);
function set_multiselect_placeholder($placeholder, $form_id) {
    return 'Click to select your options...';
}

Set different placeholders for different forms

Set different placeholder texts for different form IDs:

add_filter('gform_multiselect_placeholder', 'set_multiselect_placeholder_per_form', 10, 2);
function set_multiselect_placeholder_per_form($placeholder, $form_id) {
    if ($form_id == 1) {
        return 'Choose options for Form 1...';
    } elseif ($form_id == 2) {
        return 'Select items for Form 2...';
    } else {
        return $placeholder;
    }
}

Remove placeholder text

Remove the placeholder text entirely:

add_filter('gform_multiselect_placeholder', 'remove_multiselect_placeholder', 10, 2);
function remove_multiselect_placeholder($placeholder, $form_id) {
    return '';
}

Set placeholder based on field ID

Set different placeholder texts for different field IDs:

add_filter('gform_multiselect_placeholder', 'set_multiselect_placeholder_per_field', 10, 3);
function set_multiselect_placeholder_per_field($placeholder, $form_id, $field) {
    if ($field->id == 3) {
        return 'Choose your favorite colors...';
    } elseif ($field->id == 4) {
        return 'Select your preferred languages...';
    } else {
        return $placeholder;
    }
}

Append form and field ID to placeholder

Append form and field ID to the default placeholder text:

add_filter('gform_multiselect_placeholder', 'append_ids_to_placeholder', 10, 3);
function append_ids_to_placeholder($placeholder, $form_id, $field) {
    return $placeholder . ' (Form: ' . $form_id . ', Field: ' . $field->id . ')';
}