Description
This filter is executed before displaying each field and can be used to dynamically populate fields with a default value. Note: This filter requires that the "Allow field to be populated dynamically" option is checked in the field editor's advanced tab.
Usage
<?php
add_filter("gform_field_value_email", "populate_email");
?>
Parameters
$value
- (string) The string containing the current field value to be filtered.
Examples
The following example populates the date field with a hardcoded value. It assumes that the date field is configured to "Allow field to be populated dynamically" and that the parameter name is set to "date"
<?php
add_filter("gform_field_value_date", "populate_date");
function populate_date($value){
return "10/10/2010";
}
?>
The following example populates a 3 column list field with some values. It assumes that the list field is configured to "Allow field to be populated dynamically" and that the parameter name is set to "list"
<?php
add_filter("gform_field_value_list", "populate_list");
function populate_list($value){
return array("row 1 - col1","row 1 - col2", "row 1 - col3",
"row 2 - col1", "row 2 - col2", "row 2 - col3",
"row 3 - col1", "row 3 - col2", "row 3 - col3");
}
?>
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in forms_model.php