gform_other_choice_value

gform_other_choice_value

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description

Use this filter to change the default 「Other」 text on Radio Button fields.

Usage

add_filter( 'gform_other_choice_value', 'set_placeholder', 10, 2 );

Parameters

$placeholder string
The placeholder to be filtered. Defaults to 「Other」.

$field null
Null or the Field currently being prepared for display or being validated.

Examples

This example changes the placeholder text to 「Enter your own value」 for all fields.

add_filter( 'gform_other_choice_value', 'set_placeholder', 10, 2 );
function set_placeholder( $placeholder, $field ) {
return 'Enter your own value';
}

This example changes the placeholder text to 「My Custom Text」 only for a field with id 6 that is added to a form that has id 25.

add_filter( 'gform_other_choice_value', 'set_placeholder', 10, 2 );
function set_placeholder( $placeholder, $field ) {
if ( is_object( $field ) && 6 === $field->id && 25 === $field->formId ){ // 6 and 25 to your field id and form id number.
$placeholder = 'My Custom Text';
}
return $placeholder;
}

Placement

This code should be placed in the functions.php file of your active theme.

Since

The $field parameter was added in 2.1.1.6.

Source Code

This filter is located in GFCommon::get_other_choice_value() in common.php.

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注