Problem in custom tag validation
-
Hi, after updating from an old cf7 version (5.3.2) i’m having some problems with custom tag validations (the code worked in the version 5.3.2 ). I will not post all my code, but a part of it as i have many custom tags/validations etc.
For example, I have a custom tag in the wpcf7_init action:
wpcf7_add_form_tag( array( ‘customphone’, ‘customphone*’ ), ‘custom_fields_form_tag_handler’, array( ‘name-attr’ => true ) );In the function custom_fields_form_tag_handler I add the field data and the fields is printed in my form.
I then use the filter :
add_filter( “wpcf7_validate_customphone*”, ‘filter_wpcf7_validate_custom_fields’, 10, 2 );
where i invalidate the field with some regexp:
$result->invalidate( $tag, “Wrong format” );
and i return the $resultThe invalidation is working, as i get to the main message div (wpcf7-response-output) that “Validation errors occurred. Please confirm the fields and submit it again.”
If i enter the correct data the form is submitting and i get the email with the data as expected.
The problem is that it stopped to add the “wpcf7-not-valid” class in the custom tag field and doesnt show the invalidation message “Wrong format” under the field. Also it doesnt show the “Please fill the required fields.” if i leave the field empty.
The “Please fill the required fields.” error is shown in other text fields, just not in my custom tag fields.Is there any documentation about the changes of custom tags from version 5.3.2 to the last version and validation of these custom tags that i can read and find out what changed?
best,
The topic ‘Problem in custom tag validation’ is closed to new replies.