The gform_field_size_choices filter allows you to customize the choices for the Field Size setting in the Gravity Forms form editor.
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 as follows:small
: Small sizemedium
: Medium sizelarge
: Large size
More information
See Gravity Forms Docs: gform_field_size_choices
Examples
Add a custom size
This example demonstrates how to add a custom size to the Field Size choices.
add_filter('gform_field_size_choices', function($choices) { $choices[] = array('value' => 'custom', 'text' => 'Custom'); return $choices; });
Remove the large size option
This example shows how to remove the large size option from the Field Size choices.
add_filter('gform_field_size_choices', function($choices) { $new_choices = array_filter($choices, function($choice) { return $choice['value'] !== 'large'; }); return $new_choices; });
Rename the small size option
This example demonstrates how to rename the small size option in the Field Size choices.
add_filter('gform_field_size_choices', function($choices) { foreach ($choices as &$choice) { if ($choice['value'] === 'small') { $choice['text'] = 'Tiny'; } } return $choices; });
Add a custom size with specific width and height
This example shows how to add a custom size with specific width and height to the Field Size choices.
add_filter('gform_field_size_choices', function($choices) { $choices[] = array('value' => 'custom', 'text' => 'Custom (300x150)'); return $choices; });
Sort Field Size choices alphabetically
This example demonstrates how to sort the Field Size choices alphabetically.
add_filter('gform_field_size_choices', function($choices) { usort($choices, function($a, $b) { return strcmp($a['text'], $b['text']); }); return $choices; });