Opened 17 years ago

Closed 17 years ago

#3289 closed defect (fixed)

MultipleHiddenInput widget is missing "value_from_datadict" method.

Reported by: anonymous Owned by: Adrian Holovaty
Component: Forms Version: dev
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a custom field that handles multiple hidden integers. The field value is a list of integers.
Example:

  >>> class DaForm(forms.Form):
  ...     values = MultipleHiddenIntegerField() # My custom field. Custom "clean" method and "widget = forms.MultipleHiddenInput".

  >>> form = DaForm(initial={'values': [1, 2, 3]})
  >>> print form
  <input type="hidden" name="values" value="1" id="id_values" />
  <input type="hidden" name="values" value="2" id="id_values" />
  <input type="hidden" name="values" value="3" id="id_values" />

  >>> data = MultiValueDict()
  >>> data.setlist('values', ['1', '2', '3'])
  >>> form = DaForm(data)
  >>> print form
  <input type="hidden" name="values" value="3" id="id_values" />

As you can see, the last form does not print all inputs.
I have tracked this problem to the 'value_from_datadict' method. The class 'SelectMultiple' has a version that works perfectly.
The 'MultipleHiddenInput' widget needs this method.

Attachments (1)

widgets.diff (188 bytes ) - added by anonymous 17 years ago.
Diff for quick fix of the problem

Download all attachments as: .zip

Change History (2)

by anonymous, 17 years ago

Attachment: widgets.diff added

Diff for quick fix of the problem

comment:1 by Adrian Holovaty, 17 years ago

Resolution: fixed
Status: newclosed

(In [4311]) Fixed #3289 -- newforms: Added value_from_datadict method to MultipleHiddenInput

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