Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gw-double-confirmation-fields.php: Updated snippet to use custom validation message. #654

Conversation

saifsultanc
Copy link
Contributor

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/2214432238/46871?folderId=3808239

Summary

Added custom validation message to this snippet. This can be used as follows:

register_confirmation_fields( 404, array( 3, 4 ), "Please compare the values." );
register_confirmation_fields( 406, array( 1, 3 ), "Please correct these values" );
register_confirmation_fields( 406, array( 4, 5 ), "These should also match" );

Here is a quick screencast of the update: https://www.loom.com/share/ad511b6c0abf47d4a86b7965446a5889

@saifsultanc saifsultanc added the enhancement New feature or request label Apr 24, 2023
Copy link
Contributor

@claygriffiths claygriffiths left a comment

Choose a reason for hiding this comment

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

Nice work! I do have one potential suggestion to simplify things, but considering it looks good in your Loom, I'm good with this.

Comment on lines +76 to +80
// 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;
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 ][]. 🤔

@saifsultanc saifsultanc force-pushed the saif/update/46871-custom-validation-message-for-double-confirmation-fields branch from aaa40a8 to f15695f Compare January 10, 2025 12:04
Copy link

github-actions bot commented Jan 10, 2025

Warnings
⚠️ When ready, don't forget to request reviews on this pull request from your fellow wizards.

Generated by 🚫 dangerJS against 4a52963

@saifsultanc saifsultanc force-pushed the saif/update/46871-custom-validation-message-for-double-confirmation-fields branch from f15695f to 4a52963 Compare January 10, 2025 12:06
@saifsultanc saifsultanc merged commit eacd626 into master Jan 10, 2025
3 checks passed
@saifsultanc saifsultanc deleted the saif/update/46871-custom-validation-message-for-double-confirmation-fields branch January 10, 2025 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants