Skip to content

Commit f15695f

Browse files
committed
gw-double-confirmation-fields.php: Updat snippt to use custom validation message.
1 parent 0fcb12d commit f15695f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gravity-forms/gw-double-confirmation-fields.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function gfcf_validation( $validation_result ) {
5050
}
5151

5252
$field['failed_validation'] = true;
53-
$field['validation_message'] = 'Your values do not match.';
53+
$field['validation_message'] = $confirm_fields['validation_message'];
5454
}
5555
}
5656

@@ -60,7 +60,7 @@ function gfcf_validation( $validation_result ) {
6060
return $validation_result;
6161
}
6262

63-
function register_confirmation_fields( $form_id, $fields ) {
63+
function register_confirmation_fields( $form_id, $fields, $validation_message = 'Your values do not match.' ) {
6464
global $gfcf_fields;
6565

6666
if ( ! $gfcf_fields ) {
@@ -72,6 +72,12 @@ function register_confirmation_fields( $form_id, $fields ) {
7272
}
7373

7474
$gfcf_fields[ $form_id ][] = $fields;
75+
76+
// Get the current $fields location on array
77+
$index = count( $gfcf_fields[ $form_id ] ) - 1;
78+
79+
// store the custom validation message
80+
$gfcf_fields[ $form_id ][ $index ]['validation_message'] = $validation_message;
7581
}
7682

7783
register_confirmation_fields( 1, array( 2, 3 ) );

0 commit comments

Comments
 (0)