Hi
I have created a form with custom fields which need to be checked via PHP using a filter.
When I fill in the form and leave one of the custom fields empty to test if the validation filter works I find that the whole form does not display upon submission?
screen recording with ajax enabled
https://drive.google.com/file/d/1Hm7wMFNuAzC-4qzHqfKpMwxve4BpcXlR/view?usp=sharing
shortcode with ajax enabled
[mb_frontend_form id="product" confirmation="Your post has been successful" ajax="true"]
This is the filter check for the field 'start_date'.
add_filter( 'rwmb_frontend_validate', function( $validate, $config ) {
if ( 'product' !== $config['id'] ) {
return $validate;
}
if ( empty( $_POST['start_date'] ) ) {
$validate = 'Please correct the errors highlighted below and try again.'; // Return a custom error message
}
return $validate;
}, 10, 2 );
Also when i test this with Ajax disabled in the shortcode then the form does display after submission but all of the fields are empty and does not keep the current input values? so the user will have to re-input all of the data again.
[mb_frontend_form id="product" confirmation="Your post has been successful"]
screen recording with no ajax
https://drive.google.com/file/d/12zzQxGJBaksg0vSLQKDfWZb4SI5U3Re5/view?usp=sharing