079f87b1d2
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"
32 lines
792 B
Python
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", )
|