OpenSlides/openslides/poll/forms.py

18 lines
561 B
Python
Raw Normal View History

2012-02-15 10:43:08 +01:00
from django import forms
2012-02-15 12:36:50 +01:00
from django.utils.translation import ugettext as _
2012-02-15 10:43:08 +01:00
2012-02-15 10:43:08 +01:00
class OptionForm(forms.Form):
def __init__(self, *args, **kwargs):
extra = kwargs.pop('extra')
formid = kwargs.pop('formid')
kwargs['prefix'] = "option-%s" % formid
super(OptionForm, self).__init__(*args, **kwargs)
for key, value in extra:
self.fields[key] = forms.IntegerField(
widget=forms.TextInput(attrs={'class': 'small-input'}),
label=_(key),
initial=value,
)