Django

Code

Ticket #3442 (closed: duplicate)

Opened 1 year ago

Last modified 2 months ago

[patch] ChoiceField should allow for nested choice sets

Reported by: pmpowell@gmail.com Assigned to: thejaswi_puthraya
Component: django.newforms Version: SVN
Keywords: sprintdec01 Cc: tbarta@gmail.com,
Triage Stage: Accepted Has patch: 1
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 0

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

widgets.diff (2.2 kB) - added by tbarta@gmail.com on 02/23/07 00:50:47.
patch to add groupedSelect widget that works with existing ChoiceField class
example.py (0.7 kB) - added by tbarta@gmail.com on 02/23/07 00:51:58.
example usage of GroupedSelect
grouped_select.diff (2.4 kB) - added by thejaswi_puthraya on 12/01/07 05:36:56.
Added the GroupSelect? Widget to django.newforms.extras.widgets and added support for unicode and mark_safe

Change History

02/06/07 15:04:58 changed by Michael Radziej <mir@noris.de>

  • needs_better_patch changed.
  • stage changed from Unreviewed to Design decision needed.
  • needs_tests changed.
  • needs_docs changed.

02/19/07 18:07:59 changed by adrian

  • stage changed from Design decision needed to Accepted.

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

02/23/07 00:11:09 changed by tbarta@gmail.com

  • cc set to tbarta@gmail.com.

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.

02/23/07 00:50:47 changed by tbarta@gmail.com

  • attachment widgets.diff added.

patch to add groupedSelect widget that works with existing ChoiceField class

02/23/07 00:51:58 changed by tbarta@gmail.com

  • attachment example.py added.

example usage of GroupedSelect

02/23/07 00:54:56 changed by tbarta@gmail.com

  • has_patch set to 1.

02/23/07 06:54:53 changed by anonymous

  • summary changed from ChoiceField should allow for nested choice sets to [patch] ChoiceField should allow for nested choice sets.

12/01/07 05:05:04 changed by thejaswi_puthraya

  • owner changed from nobody to thejaswi_puthraya.

12/01/07 05:36:56 changed by thejaswi_puthraya

  • attachment grouped_select.diff added.

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

12/01/07 05:39:33 changed by thejaswi_puthraya

  • cc changed from tbarta@gmail.com to tbarta@gmail.com, .
  • keywords set to sprintdec01.
  • stage changed from Accepted to Ready for checkin.

12/01/07 17:10:02 changed by mtredinnick

  • stage changed from Ready for checkin to Accepted.

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.

03/05/08 18:30:47 changed by russellm

  • status changed from new to closed.
  • resolution set to duplicate.

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


Add/Change #3442 ([patch] ChoiceField should allow for nested choice sets)




Change Properties
Action