DescriptionUsageParametersExamples1. Add a new errorPlacementSinceSource Code
Description
The gform_form_validation_errors filter enables the list of validation errors, which will be displayed at the top of the form, to be overridden.
Usage
add_filter( 'gform_form_validation_errors', 'your_function_name', 10, 2 );
You can also specify this per form by adding the form id after the filter name.
add_filter( 'gform_form_validation_errors_6', 'your_function_name', 10, 2 );
Parameters
$errors array
An array of field validation errors. The following keys will be defined for each error: field_label, field_selector, and message.
$form Form Object
The current form object.
Examples
1. Add a new error
add_filter( 'gform_form_validation_errors', function( $errors, $form ) {
$errors[] = array( 'field_label' => 'the field label here', 'field_selector' => '#field_1_10', 'message' => 'the error message here' );
return $errors;
}, 10, 2 );
Placement
This code should be placed in the functions.php file of your active theme or a custom functions plugin.
Since
This filter was added in Gravity Forms v2.5.
Source Code
This filter is located in GFFormDisplay::get_validation_errors() in form_display.php.