Opened 10 years ago

Closed 9 years ago

#3787 closed (fixed)

[patch] newforms.widgets.MultiWidget bugfixes

Reported by: Max Derkachev <mderk@…> Owned by: Adrian Holovaty
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

I found 3 problems with MultiWidget:

  1. render() does not generate different element ids for different sub-widgets, so every sub-widget gets the same id
  2. render() checks for KeyError while enumerating self.widgets, while it should check for IndexError instead
  3. value_from_datadict() should use sub-widget.value_from_datadict() instead of using data.get (sub-widgets can be other multiwidgets or SelectMultiples)

Attachments (2)

widgets_multiwidget.patch (1.1 KB) - added by Max Derkachev <mderk@…> 10 years ago.
3787.diff (1.1 KB) - added by Gary Wilson <gary.wilson@…> 10 years ago.
diff from repository root and slightly more pythonic list comprehension using enumerate() instead of range(len())

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by Max Derkachev <mderk@…>

Attachment: widgets_multiwidget.patch added

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

Attachment: 3787.diff added

diff from repository root and slightly more pythonic list comprehension using enumerate() instead of range(len())

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

Needs documentation: unset
Needs tests: set
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

We should have some MultiWidget form-processing tests.

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

(In [5065]) Fixed #3870, Refs #3787 -- Fixed handling of widget attributes on RadioSelect and MultiWidget. In particular, handling of the id attribute has been fixed. Thanks to Gary Wilson and Max Derkachev.

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

Resolution: fixed
Status: newclosed

(In [5088]) Fixed #3787, #3788 -- Corrected check for IndexError on MultiValueField, and fixed the value_from_datadict method for MultiWidgets to handle Multiwidgets containing Multiwidgets. Also added a testcase walking through the use of MultiWidget/MultiValueField. Thanks to Max Derkachev for reporting these issues and providing fixes.

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