Ticket #11213: test-hidden-splitdatetime.diff

File test-hidden-splitdatetime.diff, 1014 bytes (added by Dennis Kaarsemaker, 15 years ago)

Add a test for this

  • regressiontests/forms/forms.py

     
    507507<input type="hidden" name="composers" value="P" />
    508508<input type="hidden" name="composers" value="J" />
    509509
     510DateTimeField rendered as_hidden() is special too
     511
     512>>> class MessageForm(Form):
     513...     when = SplitDateTimeField()
     514>>> f = MessageForm({'when_0': '1992-01-01', 'when_1': '01:01'})
     515>>> print f.is_valid()
     516True
     517>>> print f['when']
     518<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" />
     519>>> print f['when'].as_hidden()
     520<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" />
     521
    510522MultipleChoiceField can also be used with the CheckboxSelectMultiple widget.
    511523>>> class SongForm(Form):
    512524...     name = CharField()
Back to Top