Description
The gform_field_size_choices filter allows the choices for Field Size setting in the form editor to be customized.
Usage
add_filter( 'gform_field_size_choices', 'your_function_name' );
Parameters
- $choices array
An array of choices (value and text) to be included in the Field Size setting. The default choices are defined like so:
$choices = array( array( 'value' => 'small', 'text' => __( 'Small', 'gravityforms' ) ), array( 'value' => 'medium', 'text' => __( 'Medium', 'gravityforms' ) ), array( 'value' => 'large', 'text' => __( 'Large', 'gravityforms' ) ), );
Examples
1. Add custom size
This example shows how you can add a custom size.
add_filter( 'gform_field_size_choices', function( $choices ) { $choices[] = array( 'value' => 'custom', 'text' => 'Custom' ); return $choices; } );
Placement
This code can be placed in the functions.php file of your active theme or a custom functions plugin.
Since
This filter was added in Gravity Forms 2.4.18.13.
Source Code
$choices = apply_filters( 'gform_field_size_choices', $choices );
This filter is located in GF_Field::get_size_choices() in includes/fields/class-gf-field.php.