gform_input_masks

Description

Use this filter to edit the list of built-in input masks that are displayed in the Text Field input mask setting. Useful when adding a new custom input mask that will be used repeatedly.

Usage

add_filter( 'gform_input_masks', 'add_mask' );

Parameters

  • $masks array
    Current list of masks to be filtered, in the following format:
array(
    'US Phone' => '(999) 999-9999',
    'US Phone + Ext' => '(999) 999-9999? x99999',
    'Date' => '99/99/9999',
    'Tax ID' => '99-9999999',
    'SSN' => '999-99-9999',
    'Zip Code' => '99999',
    'Full Zip Code' => '99999?-9999'
);

Examples

This example adds a new predefined mask for “Product Key”.

add_filter( 'gform_input_masks', function( $masks ) {
    $masks['Product Key'] = 'a*-999-a999';
    return $masks;
} );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This filter is located in GFFormsModel::get_input_masks() in forms_model.php.