Created
June 20, 2019 17:27
-
-
Save zackkatz/80f0327f17ecce8691cafbd61b1978de to your computer and use it in GitHub Desktop.
Only allow integers (whole numbers, including negative values) in Gravity Forms Number field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Force number fields to increment by 1 | |
*/ | |
add_filter( 'gform_field_content', function ( $field_content, $field ) { | |
if ( 'number' !== $field->type ) { | |
return $field_content; | |
} | |
return str_replace( "step='any'", "step='1'", $field_content ); | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment