Opened 9 years ago

Closed 9 years ago

#3289 closed defect (fixed)

MultipleHiddenInput widget is missing "value_from_datadict" method.

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

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 9 years ago.
Diff for quick fix of the problem

Download all attachments as: .zip

Change History (2)

Changed 9 years ago by anonymous

Diff for quick fix of the problem

comment:1 Changed 9 years ago by adrian

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

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

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