Opened 8 years ago

Closed 8 years ago

#3787 closed (fixed)

[patch] newforms.widgets.MultiWidget bugfixes

Reported by: Max Derkachev <mderk@…> Owned by: adrian
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@…> 8 years ago.
3787.diff (1.1 KB) - added by Gary Wilson <gary.wilson@…> 8 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 8 years ago by Max Derkachev <mderk@…>

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

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

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

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

We should have some MultiWidget form-processing tests.

comment:2 Changed 8 years ago by russellm

(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 8 years ago by russellm

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

(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