Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Comment on lines +76 to +80
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if it'd be easier/simpler to merge validation_message into $fields when it's added to $gfcf_fields[ $form_id ][]. 🤔

}

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