[Register extra] how to display a global error message "Errors found" if errors have been found


I use the “Register” extra with Modx 2.8.

Each label has a span element for the errors to display right above the field.




The error messages in the span elements work fine.

But now, I would like to have also a short text above the form.


<legend>There are errors in the registration form</legend>

I tried the following placeholder but they are empty: [[+reg.error]],[[+reg.errors]],[[+reg.error.message]],[[+reg.errors.message]]

I think I will have to do some custom code in php.
Before I start coding this I would like to know maybe someone has a better approach than me.

I tried to use the modx input/output filters however the OR condition cannot compare two placeholders. The OR works only for a single placeholder.

I will try to do this message using php but if someone has a better solution for me please let me know :slight_smile:

If you want to show a general message when the validation fails, you can use the property validationErrorMessage and the placeholder validation_error_message

    &validationErrorMessage=`<legend>There are errors in the registration form</legend>`

or alternatively the placeholder validation_error (which is a boolean).

[[!+reg.validation_error:is=`1`:then=`<legend>There are errors in the registration form</legend>`]]

The placeholder [[!+reg.error.message]] is only filled when the validation is successful but a prehook returns an error or the register processor fails.

1 Like

Thanks a mil halftrainedharry! I have read the official documentation about this extra and this parameter/placeholder was not mentionned

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.