Opened 18 years ago

Closed 17 years ago

#3442 closed (duplicate)

[patch] ChoiceField should allow for nested choice sets

Reported by: pmpowell@… Owned by: Thejaswi Puthraya
Component: Forms Version: dev
Severity: Keywords: sprintdec01
Cc: tbarta@…, Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It would be really useful for the ChoiceField choices parameter to allow grouped sets of chioces (much like the Admin class allows for grouped fields). That way, the default widget could output HTML which encloses groups of OPTION tags within OPTGROUP tags.

Attachments (3)

widgets.diff (2.2 KB ) - added by tbarta@… 18 years ago.
patch to add groupedSelect widget that works with existing ChoiceField class
example.py (676 bytes ) - added by tbarta@… 18 years ago.
example usage of GroupedSelect
grouped_select.diff (2.4 KB ) - added by Thejaswi Puthraya 17 years ago.
Added the GroupSelect Widget to django.newforms.extras.widgets and added support for unicode and mark_safe

Download all attachments as: .zip

Change History (12)

comment:1 by Michael Radziej <mir@…>, 18 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by Adrian Holovaty, 18 years ago

Triage Stage: Design decision neededAccepted

Sure, that'd be a pretty good improvement. Please implement this as GroupedChoiceField and put it in django/newforms/extras, along with a GroupedChoiceWidget.

comment:3 by tbarta@…, 18 years ago

Cc: tbarta@… added

Do you really need a new GroupedChoiceField for this? For validation purposes, it's entirely identical (the grouping doesn't affect the HTML value at all). All you need is a way to provide grouping for rendering. As ChoiceField uses Select as a default widget, this could be done by addding a GroupedSelect that handles the grouping (either as a mapping of group-label => input-value or the other way around).

I'll work on a patch for this... it seems like unnecessary duplication to have a separate Field.

by tbarta@…, 18 years ago

Attachment: widgets.diff added

patch to add groupedSelect widget that works with existing ChoiceField class

by tbarta@…, 18 years ago

Attachment: example.py added

example usage of GroupedSelect

comment:4 by tbarta@…, 18 years ago

Has patch: set

comment:5 by anonymous, 18 years ago

Summary: ChoiceField should allow for nested choice sets[patch] ChoiceField should allow for nested choice sets

comment:6 by Thejaswi Puthraya, 17 years ago

Owner: changed from nobody to Thejaswi Puthraya

by Thejaswi Puthraya, 17 years ago

Attachment: grouped_select.diff added

Added the GroupSelect Widget to django.newforms.extras.widgets and added support for unicode and mark_safe

comment:7 by Thejaswi Puthraya, 17 years ago

Cc: tbarta@gmail.com → tbarta@gmail.com,
Keywords: sprintdec01 added
Triage Stage: AcceptedReady for checkin

comment:8 by Malcolm Tredinnick, 17 years ago

Triage Stage: Ready for checkinAccepted

How is this different from #4412? At the moment, we are favouring committing #4412 once newforms-admin has merged, so unless this adds any significantly extra functionality, let's close this as a duplicate of #4412.

comment:9 by Russell Keith-Magee, 17 years ago

Resolution: duplicate
Status: newclosed

Agreed - this is a dupe of #4412, which has a better integrated and more complete implementation (including docs and tests).

Note: See TracTickets for help on using tickets.
Back to Top