Ticket #11301: hide_label_splitdatetimefield.diff

File hide_label_splitdatetimefield.diff, 1.2 KB (added by punteney, 15 years ago)

updated patch with test case

  • django/forms/widgets.py

     
    725725    """
    726726    A Widget that splits datetime input into two <input type="hidden"> inputs.
    727727    """
     728    is_hidden = True
     729   
    728730    def __init__(self, attrs=None):
    729731        widgets = (HiddenInput(attrs=attrs), HiddenInput(attrs=attrs))
    730732        super(SplitDateTimeWidget, self).__init__(widgets, attrs)
  • tests/regressiontests/forms/forms.py

     
    18071807>>> [f.name for f in form.visible_fields()]
    18081808['artist', 'name']
    18091809
     1810
     1811# Checking that the label for SplitDateTimeField is not being displayed #####
     1812
     1813>>> from django.forms import *
     1814>>> class EventForm(Form):
     1815...     happened_at = SplitDateTimeField(widget=widgets.SplitHiddenDateTimeWidget)
     1816...
     1817>>> form = EventForm()
     1818>>> form.as_ul()
     1819u'<input type="hidden" name="happened_at_0" id="id_happened_at_0" /><input type="hidden" name="happened_at_1" id="id_happened_at_1" />'
     1820
    18101821"""
Back to Top