WAIT: Form Validation Errors Not Displaying in bricks/form/validate Bricks 1.12

Browser: Chrome 110
OS: Windows

Hi everyone,

I’m working with a Bricks form and using the bricks/form/validate filter to add custom validation.

My custom function correctly returns errors, like this ( i can see it in chrome dev tools):

add_filter( 'bricks/form/validate', function( $errors, $fields, $form ) {
   if (email_exists($email)) {
        $errors[] = esc_html__('Vous avez déjà un compte.', 'bricks');
    }
    return $errors;
}, 10, 3 );

The problem is: the errors don’t appear in the frontend form.

  • The form submits, the validation runs, but no error message shows under the field.
  • I’m expecting the error message to be displayed under the input like Bricks normally does.

Has anyone experienced this? Do I need to trigger something else for Bricks to display these custom errors?

Thanks a lot for your help!

Hi @julielabrune83 and welcome to the forum :partying_face:.

I’ve tested locally, can you try with the filter below?

add_filter(
    'bricks/form/validate', function ( $errors, $form ) {

        $errors[] = esc_html__('This email address is not in our system, sorry.', 'bricks');
    
        return $errors;
    }, 10, 2 
);

or if you need it, you have full example here: Form Element – Bricks Academy

The reason why it’s not working for you, it’s because your filter expects 3 parameters, but it got only 2.

Let me know please,
Matej

Hi @Matej ,

thank you for your feedback.
I think the function is correct because it returns the right values but the problem is with the display. (see the capture)
i’d like to point out that i don’t have any js errors.

thanks for your help

Hi @julielabrune83,

do you have a link, where I can test this?

Thanks,
Matej

hi @Matej ,
my website is currently being developed. would it be possible to exchange login information privately?

Feel free to send temporary login credentials to your website and a link to this topic to help@bricksbuilder.io using the email address you used during the purchase, then we can take a look :slight_smile:

Best regards,
Matej