Description
Use this filter to change the field's value before getting displayed on the Entry detail page. Useful when creating custom field types that require special formatting when displayed
Usage
<?php
add_filter("gform_entry_field_value", "category_names", 10, 4);
?>
Parameters
- $value
- (string) The current entry value to be filtered.
- $field
- (Field Object) The field from which the entry value was submitted.
- $lead
- (Lead Object) The current entry.
- $form
- (Form Object) The form from which the entry value was submitted.
Examples
This example assumes the original value is a comma delimited list of category IDs (ie '1,3,4'). We then break the IDs into an array, loop through each ID to get the category name, and format the category name into an unordered list (example output: [1]).
<?php
add_filter("gform_entry_field_value", "category_names", 10, 4);
function category_names($value, $field, $lead, $form){
if($form["id"] != 104 || $field["id"] != 3)
return $value;
$newvalue = '';
$categories = explode(',', $value);
foreach($categories as $category) {
$new_value .= '<li>' . get_cat_name($category) . '</li>';
}
return '<ul>' . $new_value . '</ul>';
}
?>
Additional Notes
This hook is useful for storing entry values in one format, while displaying them on the entries page in another (refer to the example above).
Source Code
This filter is located in entry_detail.php