Opened 9 years ago

Closed 9 years ago

#4622 closed (fixed)

SelectDateWidget doesn't accept its as_hidden rendering

Reported by: Bill Fenner <fenner@…> Owned by: adrian
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


An apparently little-known fact about widgets that implement get_value_from_datadict is that they need to be able to accept whatever the widget returns for its "as_hidden" value as input. Otherwise, a form that uses as_hidden to propogate values from previous forms will fail:

>>> a = GetDate({'mydate_month':'4', 'mydate_day':'1', 'mydate_year':'2008'})
>>> print a['mydate'].as_hidden()
<input type="hidden" name="mydate" value="2008-4-1" id="id_mydate" />
>>> b=GetDate({'mydate':'2008-4-1'})
>>> print b.is_valid()

The attached diff has a fix for this problem, and a test.

Attachments (1)

SelectDateWidget.diff (1.6 KB) - added by Bill Fenner <fenner@…> 9 years ago.
A one-line diff and 29 lines of test ;-)

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by Bill Fenner <fenner@…>

A one-line diff and 29 lines of test ;-)

comment:1 Changed 9 years ago by Simon G. <dev@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

1:29 code:test ratio? how very agile of you :)

comment:2 Changed 9 years ago by Bill Fenner <fenner@…>

I was just tired of seeing needs_tests => 1 ;-)

comment:3 Changed 9 years ago by mtredinnick

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

(In [5859]) Fixed #4622 -- Fixed SelectDateWidget to work correctly when used as a hidden input field. Thanks, Bill Fenner.

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