From a6bb3f8a04481d8126dc4f1d3fef39f25b1984e7 Mon Sep 17 00:00:00 2001 From: Steven Loria Date: Sun, 8 Dec 2013 03:07:41 -0600 Subject: [PATCH] Less verbose form errors --- .../{{cookiecutter.repo_name}}/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/utils.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/utils.py index 47080ba..bfaf4fe 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/utils.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/utils.py @@ -2,9 +2,9 @@ '''Helper utilities and decorators.''' from flask import flash -def flash_errors(form): +def flash_errors(form, category="warning"): '''Flash all errors for a form.''' for field, errors in form.errors.items(): for error in errors: - flash("Error in {0} field - {1}" - .format(getattr(form, field).label.text, error), 'warning') + flash("{0} - {1}" + .format(getattr(form, field).label.text, error), category)