Code

Opened 7 years ago

Closed 7 years ago

#5173 closed (worksforme)

Formsets - Empty form fields display validation errors

Reported by: Simon Litchfield <simon@…> Owned by: adrian
Component: Forms Version: newforms-admin
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

The formsets tests seem fine. However, when you actually display the fields, it causes them to bind, clean, and throw validation errors even though the forms are empty.

Forms who are part of a formset, should know to check is_empty (or similar) before binding and cleaning their fields.

Attachments (1)

formsets-empty-forms-5897.diff (1.2 KB) - added by Simon Litchfield <simon@…> 7 years ago.
Quick hack to fix the problem, against rev 5897

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by Simon Litchfield <simon@…>

Quick hack to fix the problem, against rev 5897

comment:1 Changed 7 years ago by Simon Litchfield <simon@…>

  • Has patch set
  • Needs documentation unset
  • Needs tests set
  • Owner changed from adrian to anonymous
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Design decision needed

Also fixes which on surface seems to be a small typo in _get_change_forms().

comment:2 Changed 7 years ago by anonymous

  • Owner changed from anonymous to adrian
  • Status changed from assigned to new

comment:3 Changed 7 years ago by jkocherhans

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

Can you give some more details on what you are doing here? The empty add forms are reset when you call full_clean on the FormSet. I'm not able to reproduce this. The code from the view that produces this problem would probably be sufficient. Your solution may be better, but I haven't though it through yet. Either way seems really hackish. I'm closing this for now, but please reopen it if you post an example that triggers this.

Here's a link to the reset code:
http://code.djangoproject.com/browser/django/branches/newforms-admin/django/newforms/formsets.py#L122

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.