gform_gf_field_create

Description

Use this filter to modify or replace the GF_Field object after it has been created.

Usage

add_filter( 'gform_gf_field_create', 'my_custom_function', 10, 2 );

Parameters

  • $field GF_Field

    A GF_Field object of the type specified by the $properties['type'] or $properties['inputType'] properties.

  • $properties array

    An array of field properties that will be used to generate the GF_Field object.

Examples

1. Create GF_Field object based on “type” property (rather than “inputType” property)

add_filter( 'gform_gf_field_create', 'my_custom_function', 10, 2 );
function my_custom_function( $field, $properties ) {
if( $field->type == 'myCustomFieldType' ) {
$field = new GF_My_Custom_Field_Type( $properties );
}
return $field;
}

Source Code

This filter is located in GF_Fields::create() in includes/addon/class-gf-fields.php.

Since

This filter was added in Gravity Forms 2.0.