Skip to content

Commit 631bb7d

Browse files
committed
Added a test for hidden SplitDateTime fields. Thanks, seveas.
Fixed #11213 git-svn-id: http://code.djangoproject.com/svn/django/trunk@13816 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 1e7b2f5 commit 631bb7d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/regressiontests/forms/forms.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,18 @@
522522
<input type="hidden" name="composers" value="P" />
523523
<input type="hidden" name="composers" value="J" />
524524
525+
DateTimeField rendered as_hidden() is special too
526+
527+
>>> class MessageForm(Form):
528+
... when = SplitDateTimeField()
529+
>>> f = MessageForm({'when_0': '1992-01-01', 'when_1': '01:01'})
530+
>>> print f.is_valid()
531+
True
532+
>>> print f['when']
533+
<input type="text" name="when_0" value="1992-01-01" id="id_when_0" /><input type="text" name="when_1" value="01:01" id="id_when_1" />
534+
>>> print f['when'].as_hidden()
535+
<input type="hidden" name="when_0" value="1992-01-01" id="id_when_0" /><input type="hidden" name="when_1" value="01:01" id="id_when_1" />
536+
525537
MultipleChoiceField can also be used with the CheckboxSelectMultiple widget.
526538
>>> class SongForm(Form):
527539
... name = CharField()

0 commit comments

Comments
 (0)