How to change Deform Default validation fail error message?

147 Views Asked by At

I need to change the deform validation error message

'There was a problem with your submission Errors have been highlighted below'.

How can I customize my own error message or hide this error message?

enter image description here

1

There are 1 best solutions below

0
Steve Piercy On

You can override any Chameleon template that Deform uses.

To determine which template to override, search the Deform package source code for the string you want to modify, in this case, "There was a problem with your submission". You will find templates/form.pt.

Create a directory in your package's root, say templates/_deform/, to hold your template overrides.

In your Pyramid application, specify where you store your template overrides. Then in your application's __init__.py:

from deform.renderer import configure_zpt_renderer

# other stuff

def main(global_config, **settings):

    # configuration stuff

    configure_zpt_renderer(["mypackage:templates/_deform"])

Finally copy the template form.pt from the Deform package to the overrides folder that you created. This template will override the Deform default. Edit its strings as needed.

If you use internationalization, you should instead edit the language's translation file, instead of following the above procedure.