Opened 6 years ago

Last modified 2 years ago

#9061 new New feature

formsets with can_delete=True shouldn't add delete field to extra forms

Reported by: gsf Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Current behavior of formsets with can_delete=True is to add a delete field to every form. This behavior differs from that expected, however (why would one want a delete option on an "add" form?), as well as that of the builtin admin. I've included a patch on formsets.py, but haven't bothered with patching tests yet.

Attachments (3)

no_delete_formsets_extra.diff (673 bytes) - added by gsf 6 years ago.
don't add delete field to formset extra forms
t9061-a.diff (1.3 KB) - added by gsf 6 years ago.
newer diff with edit to forms.models to avoid error on save
formsets.py.diff (202 bytes) - added by oban 3 years ago.
updated patch for 1.3.1

Download all attachments as: .zip

Change History (11)

Changed 6 years ago by gsf

don't add delete field to formset extra forms

Changed 6 years ago by gsf

newer diff with edit to forms.models to avoid error on save

comment:1 Changed 6 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

I thought brosner already had done this. Seems a valid issue, anyway.

comment:2 Changed 6 years ago by gsf

Having lived with this for a while, I can see the case where one might want a delete field on extra forms. I'd still argue that it shouldn't be the default, but it could be another option on formsets. Perhaps delete_extra or extra_delete?

comment:3 Changed 6 years ago by jkocherhans

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

I don't think this is the case on trunk anymore. I don't see delete checkboxes for "add" forms.

comment:4 Changed 6 years ago by Matthew

  • Resolution fixed deleted
  • Status changed from closed to reopened

The delete fields still appear here on all rows with the latest trunk, r11468.

from django import forms
class Form(forms.Form):
    test = forms.CharField()

FormSet = forms.formsets.formset_factory(Form, can_delete=1)
formset = FormSet(initial=[{'test':'Some initial data for the first row'}])

The formset contains two rows, both of which have a delete checkbox.

comment:5 Changed 4 years ago by lukeplant

  • Severity set to Normal
  • Type set to New feature

Changed 3 years ago by oban

updated patch for 1.3.1

comment:6 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:7 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:8 Changed 2 years ago by aaugustin

  • Status changed from reopened to new
Note: See TracTickets for help on using tickets.
Back to Top