Skip to content

Instantly share code, notes, and snippets.

@hirejordansmith
Created December 30, 2016 15:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hirejordansmith/a646fad49b0bd287ca43832050352750 to your computer and use it in GitHub Desktop.
Save hirejordansmith/a646fad49b0bd287ca43832050352750 to your computer and use it in GitHub Desktop.
Convert a Gravity Forms Text Field into a Tel Field
<?php
add_filter( 'gform_field_input', 'hjs_change_input_type', 10, 5 );
function hjs_change_input_type( $input, $field, $value, $lead_id, $form_id ) {
// Replace "9" with your form ID
// Replace "3" with your field ID
// Replace tabindex="1" with the tabindex value of the field being overwritten
if ( $form_id == 9 && $field->id == 3 ) {
$input = '
<div class="ginput_container ginput_container_text">
<input name="input_' . $form_id . '" id="input_' . $form_id . '_' . $field->id .'" type="tel" class="medium" value="' . $value . '" tabindex="1">
</div>';
}
return $input;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment