Commit 264ea9c8 authored by Daniel W Bond's avatar Daniel W Bond

moved 'form-control' css classes to forms.py from views.py

parent bdb750ba
......@@ -73,7 +73,9 @@ class BooleanRadioField(forms.TypedChoiceField):
class StudentUpdateForm(forms.Form):
first_name = forms.CharField(required=False, max_length=30)
first_name.widget.attrs['class'] = 'form-control'
last_name = forms.CharField(required=False, max_length=30)
last_name.widget.attrs['class'] = 'form-control'
gender = MultiSelectFormField(choices=Student.GENDER_CHOICES,
required=False)
show_gender = BooleanRadioField(required=True)
......@@ -82,12 +84,14 @@ class StudentUpdateForm(forms.Form):
room = SelectRoomField(queryset=Room.objects.all(), required=False)
privacy = forms.TypedChoiceField(choices=Student.PRIVACY_CHOICES)
privacy.widget.attrs['class'] = 'form-control'
# exclude self from request in form instantiation
blocked_kids = forms.ModelMultipleChoiceField(queryset=Student.objects.all(),
required=False)
major = forms.ModelMultipleChoiceField(queryset=Major.objects.all(), required=False)
graduating_year = forms.IntegerField(max_value=9999, min_value=-9999, required=False)
graduating_year.widget.attrs['class'] = 'form-control'
def clean(self):
cleaned_data = super(StudentUpdateForm, self).clean()
......
......@@ -218,14 +218,9 @@ class UpdateStudent(LoginRequiredMixin, FormValidMessageMixin, FormView):
else:
form.fields['room'].widget.user = self.request.user
# bootstrap
form.fields['first_name'].widget.attrs['class'] = 'form-control'
form.fields['last_name'].widget.attrs['class'] = 'form-control'
form.fields['graduating_year'].widget.attrs['class'] = 'form-control'
# chosen
form.fields['major'].widget.attrs['class'] = 'chosen-select'
form.fields['blocked_kids'].widget.attrs['class'] = 'blocked-select'
form.fields['major'].widget.attrs['class'] = 'form-control chosen-select'
form.fields['blocked_kids'].widget.attrs['class'] = 'form-control blocked-select'
context['my_form'] = form
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment