diff --git a/src/registrar/forms/__init__.py b/src/registrar/forms/__init__.py index c3aa89fed..914db375c 100644 --- a/src/registrar/forms/__init__.py +++ b/src/registrar/forms/__init__.py @@ -5,6 +5,7 @@ from .domain import ( DomainSecurityEmailForm, DomainOrgNameAddressForm, ContactForm, + AuthorizingOfficialContactForm, DomainDnssecForm, DomainDsdataFormset, DomainDsdataForm, diff --git a/src/registrar/forms/domain.py b/src/registrar/forms/domain.py index 44dac3a9b..717204019 100644 --- a/src/registrar/forms/domain.py +++ b/src/registrar/forms/domain.py @@ -147,6 +147,9 @@ class ContactForm(forms.ModelForm): for field_name in self.required: self.fields[field_name].required = True + + # Set custom form label + self.fields["middle_name"].label = "Middle name (optional)" # Set custom error messages self.fields["first_name"].error_messages = {'required': 'Enter your first name / given name.'} @@ -159,6 +162,23 @@ class ContactForm(forms.ModelForm): } self.fields["phone"].error_messages = {'required': 'Enter your phone number.'} +class AuthorizingOfficialContactForm(ContactForm): + """Form for updating authorizing official contacts.""" + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # Set custom error messages + self.fields["first_name"].error_messages = {'required': 'Enter the first name / given name of this contact.'} + self.fields["last_name"].error_messages = {'required': 'Enter the last name / family name of this contact.'} + self.fields["title"].error_messages = { + 'required': 'Enter the title or role in your organization of this contact \ + (e.g., Chief Information Officer).' + } + self.fields["email"].error_messages = { + 'required': 'Enter an email address in the required format, like name@example.com.' + } + self.fields["phone"].error_messages = {'required': 'Enter a phone number for this contact.'} + class DomainSecurityEmailForm(forms.Form): """Form for adding or editing a security email to a domain.""" diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index 88fad1567..0dad7115e 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -33,6 +33,7 @@ from registrar.models.utility.contact_error import ContactError from ..forms import ( ContactForm, + AuthorizingOfficialContactForm, DomainOrgNameAddressForm, DomainAddUserForm, DomainSecurityEmailForm, @@ -182,7 +183,7 @@ class DomainAuthorizingOfficialView(DomainFormBaseView): model = Domain template_name = "domain_authorizing_official.html" context_object_name = "domain" - form_class = ContactForm + form_class = AuthorizingOfficialContactForm def get_form_kwargs(self, *args, **kwargs): """Add domain_info.authorizing_official instance to make a bound form."""