Skip to content

Commit

Permalink
gw-double-confirmation-fields.php: Updated snippet to use custom va…
Browse files Browse the repository at this point in the history
…lidation message.
  • Loading branch information
saifsultanc authored Jan 10, 2025
1 parent 87fd28a commit eacd626
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gravity-forms/gw-double-confirmation-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function gfcf_validation( $validation_result ) {
}

$field['failed_validation'] = true;
$field['validation_message'] = 'Your values do not match.';
$field['validation_message'] = $confirm_fields['validation_message'];
}
}

Expand All @@ -60,7 +60,7 @@ function gfcf_validation( $validation_result ) {
return $validation_result;
}

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

if ( ! $gfcf_fields ) {
Expand All @@ -72,6 +72,12 @@ function register_confirmation_fields( $form_id, $fields ) {
}

$gfcf_fields[ $form_id ][] = $fields;

// Get the current $fields location on array
$index = count( $gfcf_fields[ $form_id ] ) - 1;

// store the custom validation message
$gfcf_fields[ $form_id ][ $index ]['validation_message'] = $validation_message;
}

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

0 comments on commit eacd626

Please sign in to comment.