Opened 10 years ago

Closed 6 years ago

Last modified 4 years ago

#3706 closed Uncategorized (wontfix)

[patch] Support for nested/compound forms for newforms

Reported by: Jeroen van Dongen <jeroen at jkwadraat.net> Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords: nested compound subforms superform formlist
Cc: joost@…, samdolan@…, woolford.thomas@…, German M. Bravo Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

The attached file contains a few classes to provide the ability to nest forms in forms.
See also http://groups.google.com/group/django-developers/t/b39ec8990e756b53.

Attachments (4)

superforms.py (15.4 KB) - added by Jeroen van Dongen <jeroen at jkwadraat.net> 10 years ago.
superform.py (12.9 KB) - added by sdolan 6 years ago.
Updated version to work w/1.2 (should work with all 1.0+).
superform.2.py (13.0 KB) - added by sdolan 6 years ago.
Removed a debug raise statement that slipped by.
superforms.2.py (13.2 KB) - added by mnbayazit 6 years ago.
Added iter, getitem, and save()

Download all attachments as: .zip

Change History (15)

Changed 10 years ago by Jeroen van Dongen <jeroen at jkwadraat.net>

Attachment: superforms.py added

comment:1 Changed 10 years ago by Jeroen van Dongen <jeroen at jkwadraat.net>

In the current state it's useable except for the FormList functionality. There's something wrong with it (see Known bugs in the attached file), but I've currently no time to hunt it down, has to wait 'till later this week.

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

Patch needs improvement: set
Triage Stage: UnreviewedDesign decision needed

Have you looked at the FormSet code recently added to django.newforms.formsets in the newforms-admin branch?

comment:3 Changed 9 years ago by Brian Rosner

Resolution: worksforme
Status: newclosed

I am closing this ticket as support for this is already in newforms-admin in django.newforms.formsets.

comment:4 Changed 8 years ago by Joost Cassee

Cc: joost@… added

As I see it this is not at all like the FormSet. The FormSet is about multiple forms *of the same type*, while superform.py allow compound or nested forms. See the doctest code.

I believe this functionality is not yet present in Django. Please reopen if I am correct.

comment:5 Changed 8 years ago by mccartney

I confirm, form sets are something different.
I would vote for having the nested forms.

Changed 6 years ago by sdolan

Attachment: superform.py added

Updated version to work w/1.2 (should work with all 1.0+).

comment:6 Changed 6 years ago by sdolan

Cc: samdolan@… added

I updated this patch in response to a stack overflow question http://stackoverflow.com/questions/3114656/django-compound-nested-subforms. I removed the doctests, and added unittests (in my own "django-common" repository) that have ~90% coverage covering the different form combinations (ModelForms, multiple SubForms, and mixed Fields + SubForms). If this is something people are interested I can work up a patch that integrates the SubForm class into the Django core with accompanying unit tests/docs.

comment:7 Changed 6 years ago by twoolie

Cc: woolford.thomas@… added

I think that if people knew about this patch they would be VERY interrested. This could make complicated form creation far easier by removing the mix an math approach of putting a ton of tiny forms in a template and combining all the data manually in one's view.

Changed 6 years ago by sdolan

Attachment: superform.2.py added

Removed a debug raise statement that slipped by.

Changed 6 years ago by mnbayazit

Attachment: superforms.2.py added

Added iter, getitem, and save()

comment:8 Changed 6 years ago by cato

Easy pickings: unset
Resolution: worksforme
Severity: Normal
Status: closedreopened
Type: Uncategorized

Still not reviewed.

comment:9 Changed 6 years ago by Russell Keith-Magee

Resolution: wontfix
Status: reopenedclosed

It wasn't reviewed because the fundamental idea was rejected. If you think the idea should be reconsidered, you need to start a discussion on Django-dev, not just reopen the ticket.

comment:10 Changed 5 years ago by Antti Kaihola

UI/UX: unset

Why not make a reusable app out of this patch and put it on PyPI and djangopackages.com? Wouldn't it make sense since the patch doesn't modify Django at all, just adds some classes.

comment:11 Changed 4 years ago by German M. Bravo

Cc: German M. Bravo added
Note: See TracTickets for help on using tickets.
Back to Top