﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35243	Add easy access to error codes in forms	Christophe Henry	nobody	"The `ValidationError` has a `code` field that can be used in views to determined what exactly failed during form validation. Unfortunately, the list of error codes in not easily accessible from form. Actually, if I want to recover the `ValidationError.code`s for a form's particular field, I must write the following:

{{{#!python
error_codes = [err.code for err in form.errors.get(""field"", ErrorList()).data]
}}}

I propose to add an `error_codes` property to the `Form` class as follows:

{{{#!python
@property
def errors_codes(self):
    """"""Return the list of error codes for each field of this form.""""""
    if self._errors_codes is None:
        self._errors_codes = {
            field: [error.code for error in errors.data if error.code]
            for field, errors in self.errors.items()
        }
    return self._errors_codes
}}}"	New feature	closed	Forms	5.0	Normal	wontfix			Unreviewed	0	0	0	0	0	0
