comparison sat_website/forms.py @ 95:dc8a30f6c369

fixes the display of form results which was ignoring some labels
author souliane <souliane@mailoo.org>
date Thu, 25 Jun 2015 14:39:52 +0200
parents c1b77f07f644
children c868187b8d00
comparison
equal deleted inserted replaced
94:c1b77f07f644 95:dc8a30f6c369
42 class BooleanField(forms.BooleanField): 42 class BooleanField(forms.BooleanField):
43 def __init__(self, *args, **kwargs): 43 def __init__(self, *args, **kwargs):
44 super(BooleanField, self).__init__(*args, **kwargs) 44 super(BooleanField, self).__init__(*args, **kwargs)
45 45
46 class CharField(forms.CharField): 46 class CharField(forms.CharField):
47 def __init__(self, label=None, *args, **kwargs): 47 def __init__(self, *args, **kwargs):
48 try: 48 try:
49 placeholder = kwargs.pop('placeholder') 49 placeholder = kwargs.pop('placeholder')
50 except KeyError: 50 except KeyError:
51 placeholder = label 51 placeholder = kwargs['label']
52 52
53 super(CharField, self).__init__(*args, **kwargs) 53 super(CharField, self).__init__(*args, **kwargs)
54 self.widget.attrs.update({'class': "form-control", 54 self.widget.attrs.update({'class': "form-control",
55 'placeholder': placeholder}) 55 'placeholder': placeholder})
56 56