| CARVIEW |
Select Language
HTTP/2 301
date: Tue, 30 Dec 2025 08:51:20 GMT
content-type: text/html; charset=UTF-8
location: https://docs.gravityforms.com/gform_trim_input_value/
server: cloudflare
strict-transport-security: max-age=604800
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-frame-options: SAMEORIGIN
content-security-policy: frame-ancestors 'self';
referrer-policy: no-referrer
referrer-policy: strict-origin-when-cross-origin
x-redirect-by: WordPress
fastcgi-cache: MISS
cf-cache-status: DYNAMIC
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=wHmkRYbmy3vz4Lggb%2BUCqFoLsBNFvxAZxh0wVpiux1GwpKZzRdcdTiyBIq8kumUcc7c5jyqNcO9yGBJ3NMbStOojRqMAhQT4z6pGvb5kPAx%2Bx9Pg"}]}
cf-ray: 9b604b6dd95fc469-BLR
HTTP/2 200
date: Tue, 30 Dec 2025 08:51:20 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
vary: Accept-Encoding
strict-transport-security: max-age=604800
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-frame-options: SAMEORIGIN
content-security-policy: frame-ancestors 'self';
referrer-policy: no-referrer
referrer-policy: strict-origin-when-cross-origin
link: ; rel="https://api.w.org/"
link: ; rel="alternate"; title="JSON"; type="application/json"
link: ; rel=shortlink
fastcgi-cache: HIT
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=cESaFfRBt1ONJCjoS4o9V4E5r678BDPqKYcZjCjCOgG%2F7B6kVHmYlHn%2FcI2lRx9YNM%2FKFAwzzrTxo9MNz8UOR75OAi7qQpqt2SFJwGV0X%2BX69ioP"}]}
cf-cache-status: DYNAMIC
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
content-encoding: gzip
cf-ray: 9b604b74cdabc469-BLR
gform_trim_input_value - Gravity Forms Documentation
gform_trim_input_value
Description
Leading and trailing blank spaces are trimmed from all submitted form fields by default. Use this hook to disable that behavior so that the submitted values are left as is.
Usage
add_filter( 'gform_trim_input_value', 'disable_trim', 10, 3 );
Parameters
- $do_trim boolean
The value being filtered. True to trim the value of the current field. False to disable trimming.
-
$form_id integer
The ID of the current form
-
$field Field Object
The current field
Examples
The following example demonstrates how to disable trimming for a specific field of a form.
add_filter( 'gform_trim_input_value', 'disable_trim', 10, 3 );
function disable_trim( $do_trim, $form_id, $field ) {
if ( $form_id == 36 && $field->id == '1' ) {
return false;
}
return $do_trim;
}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in the following methods in forms_model.php
- GFFormsModel::maybe_trim_input()
- GFFormsModel::trim_form_meta_values()
- GFFormsModel::trim_conditional_logic_values_from_element()