diff --git a/smash/web/forms/subject_forms.py b/smash/web/forms/subject_forms.py index 008ab88238188f249a20755f215103846a57f11c..b4f12f65c5eb51b4bf0f221517d04123fc49387e 100644 --- a/smash/web/forms/subject_forms.py +++ b/smash/web/forms/subject_forms.py @@ -1,9 +1,9 @@ from django import forms from django.forms import ModelForm +from web.forms.forms import DATEPICKER_DATE_ATTRS from web.models import Subject from web.models.constants import COUNTRY_OTHER_ID -from web.forms.forms import DATEPICKER_DATE_ATTRS def validate_subject_country(self, cleaned_data): @@ -11,12 +11,19 @@ def validate_subject_country(self, cleaned_data): self.add_error('country', "Select valid country") +FIELD_ORDER = ["first_name", "last_name", "sex", "date_born", "social_security_number", + "default_written_communication_language", "languages", "phone_number", "phone_number_2", + "phone_number_3", "address", "city", "postal_code", "country"] + + class SubjectAddForm(ModelForm): date_born = forms.DateField(label="Date of birth", widget=forms.DateInput(DATEPICKER_DATE_ATTRS, "%Y-%m-%d"), required=False ) + field_order = FIELD_ORDER + class Meta: model = Subject fields = '__all__' @@ -34,6 +41,8 @@ class SubjectEditForm(ModelForm): required=False ) + field_order = FIELD_ORDER + def __init__(self, *args, **kwargs): was_dead = kwargs.get('was_dead', False) if 'was_dead' in kwargs: @@ -51,6 +60,8 @@ class SubjectEditForm(ModelForm): class SubjectDetailForm(ModelForm): + field_order = FIELD_ORDER + class Meta: model = Subject fields = '__all__'