Code

Ticket #11213: test-hidden-splitdatetime.diff

File test-hidden-splitdatetime.diff, 1014 bytes (added by seveas, 5 years ago)

Add a test for this

Line 
1Index: regressiontests/forms/forms.py
2===================================================================
3--- regressiontests/forms/forms.py      (revision 11211)
4+++ regressiontests/forms/forms.py      (working copy)
5@@ -507,6 +507,18 @@
6 <input type="hidden" name="composers" value="P" />
7 <input type="hidden" name="composers" value="J" />
8 
9+DateTimeField rendered as_hidden() is special too
10+
11+>>> class MessageForm(Form):
12+...     when = SplitDateTimeField()
13+>>> f = MessageForm({'when_0': '1992-01-01', 'when_1': '01:01'})
14+>>> print f.is_valid()
15+True
16+>>> print f['when']
17+<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" />
18+>>> print f['when'].as_hidden()
19+<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" />
20+
21 MultipleChoiceField can also be used with the CheckboxSelectMultiple widget.
22 >>> class SongForm(Form):
23 ...     name = CharField()