Skip to content

Commit 5146a36

Browse files
authored
gppa-ignore-required-validation-when-no-results.php: Added a new snippet to ignore required validation when the specified field has no results.
1 parent 19b7c33 commit 5146a36

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Populate Anything // Ignore Required Validation for Fields w/ No Results
4+
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
5+
*/
6+
// Update "123" to your form ID and "4" to your Populate-Anything-populated field ID.
7+
add_filter( 'gform_field_validation_123_4', function( $result, $value, $form, $field ) {
8+
if ( ! $result['is_valid'] && $result['message'] === __( 'This field is required.', 'gravityforms' ) && $field->choices[0]['gppaErrorChoice'] === 'no_choices' ) {
9+
$result['is_valid'] = true;
10+
$result['message'] = '';
11+
}
12+
return $result;
13+
}, 10, 4 );

0 commit comments

Comments
 (0)