symposion_app/pinaxcon/registrasion/forms.py
Sachi King 079f87b1d2 Use a selectbox for of_legal_age
To me, this registeres to a user as a required field better than a
radio-button.

As well, we now signal it as "required = True"
2017-04-23 17:19:38 +10:00

32 lines
792 B
Python

from . import models
from django import forms
class YesNoField(forms.TypedChoiceField):
def __init__(self, *args, **kwargs):
kwargs['required'] = True
super(YesNoField, self).__init__(
*args,
coerce=lambda x: x == True,
choices=((None, '--------'), (False, 'No'), (True, 'Yes')),
**kwargs
)
class ProfileForm(forms.ModelForm):
''' A form for requesting badge and profile information. '''
class Meta:
model = models.AttendeeProfile
exclude = ['attendee']
widgets = {
'past_lca': forms.widgets.CheckboxSelectMultiple
}
field_classes = {
"of_legal_age": YesNoField,
}
class Media:
js = ("lca2017/js/profile_form.js", )