Code

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#3718 closed (fixed)

newforms.Form.clean should have access to field errors

Reported by: arve.knudsen@… Owned by: adrian
Component: Forms Version: master
Severity: Keywords:
Cc: gary.wilson@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I'm implementing a newforms.Form subclass in which I do form-wide validation in clean(). I'm missing the ability to check for errors detected during field validation though, I can only determine this by looking for missing entries in clean_data. Can you please expose field validation errors to the Form.clean hook?

Attachments (1)

3718.diff (2.0 KB) - added by Gary Wilson <gary.wilson@…> 7 years ago.
Save to self.__errors sooner in full_clean() so that the clean methods can access errors.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 7 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 7 years ago by Gary Wilson <gary.wilson@…>

And currently, looking at clean_data doesn't work in all cases since fields that pass validation but not the clean_XXX method still have their data in clean_data (the patch attached to #3896 would fix this problem though).

Changed 7 years ago by Gary Wilson <gary.wilson@…>

Save to self.__errors sooner in full_clean() so that the clean methods can access errors.

comment:3 Changed 7 years ago by Gary Wilson <gary.wilson@…>

  • Has patch set

comment:4 Changed 7 years ago by Gary Wilson <gary.wilson@…>

  • Cc gary.wilson@… added

comment:5 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [5348]) Fixed #3718 -- Exposed form errors to cleaning methods as soon as they are
available. Patch from Gary Wilson.

comment:6 Changed 7 years ago by mtredinnick

(In [5354]) Added a new form test that I forgot to commit in [5348]. Refs #3718.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.