﻿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
7229	newforms-admin does not display validation errors that aren't associated with a particular field	simon	nobody	"If you attempt to add custom validation to a newforms-admin model adding/editing page that runs against more than one field (and hence should be in the form's ""clean"" method, rather than a clean method associated with a particular field) you run in to problems. Here's the example code:
{{{
def custom_clean(self):
    image_url = self.cleaned_data.get('image_url', None)
    image = self.cleaned_data.get('image', None)
    if not image and not image_url:
        raise forms.ValidationError(""You must upload OR enter an image"")
    return self.cleaned_data

class EntryOptions(admin.ModelAdmin):
    
    def get_form(self, request, obj=None):
        form = super(EntryOptions, self).get_form(request, obj)
        form.clean = custom_clean
        return form
}}}
This works in as much as you get a message about there being errors on the page, but the actual errors are not displayed anywhere. They should be displayed in a list at the top of the page.

Forms have a non_field_errors() method that can be used for this purpose."		closed	contrib.admin	newforms-admin		duplicate	nfa-blocker		Unreviewed	0	0	0	0	0	0
