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
Parameter | Type | Description |
---|---|---|
$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
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;
}
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 GF_Fields::create() in includes/addon/class-gf-fields.php.
Since
This filter was added in Gravity Forms 2.0.