Last active
January 17, 2022 14:11
-
-
Save cliffordp/551eb4f67b8db8e19d3d59a0f2b7a6f9 to your computer and use it in GitHub Desktop.
Usage examples that require https://github.com/cliffordp/gf-gw-req-char-length version 2.0.0+.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Usage examples that require https://github.com/cliffordp/gf-gw-req-char-length version 2.0.0+. | |
* | |
* This gist's changelog: | |
* | |
* Version 1.0.0 - October 26, 2018 | |
* - Initial version of this gist example. | |
*/ | |
if ( class_exists( 'GF_GW_Req_Char_Length' ) ) { | |
/** | |
* Example Usage: Field 1 from Form 524 must be 4-5 characters long. | |
*/ | |
new GF_GW_Req_Char_Length( | |
[ | |
'form_id' => 524, | |
'field_id' => 1, | |
'min_chars' => 4, | |
'max_chars' => 5, | |
'min_validation_message' => esc_html__( 'Oops! You need to enter at least %d characters.' ), | |
'max_validation_message' => esc_html__( 'Oops! You can only enter %d characters.' ) | |
] | |
); | |
/** | |
* Example Usage: Field 7 from Form 322 is an Address field and therefore Field ID 7.1 is the Address Line 1, and it | |
* must be 5-30 characters long. | |
*/ | |
new GF_GW_Req_Char_Length( | |
[ | |
'form_id' => 322, | |
'field_id' => 7.1, | |
'min_chars' => 5, | |
'max_chars' => 30, | |
'min_validation_message' => esc_html__( 'Oops! Address Line 1 must be at least %d characters.' ), | |
'max_validation_message' => esc_html__( 'Oops! Address Line 1 must be %d or fewer characters.' ) | |
] | |
); | |
/** | |
* Example Usage: Field 1 from Form 746 is a Name field and therefore Field ID 1.3 is the First Name and 1.6 is the | |
* Last Name and both have the same validation of 2-40 characters long. Use the default validation message text. | |
*/ | |
new GF_GW_Req_Char_Length( | |
[ | |
'form_id' => 746, | |
'field_id' => [ 1.3, 1.6 ], | |
'min_chars' => 2, | |
'max_chars' => 40, | |
] | |
); | |
} // end of class_exists() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment