mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-05 17:28:31 +02:00
Merge pull request #1375 from cisagov/es/984-refine-error-messages
#984: Update form error messages on domain management contacts
This commit is contained in:
commit
5ae14c964a
3 changed files with 37 additions and 1 deletions
|
@ -5,6 +5,7 @@ from .domain import (
|
|||
DomainSecurityEmailForm,
|
||||
DomainOrgNameAddressForm,
|
||||
ContactForm,
|
||||
AuthorizingOfficialContactForm,
|
||||
DomainDnssecForm,
|
||||
DomainDsdataFormset,
|
||||
DomainDsdataForm,
|
||||
|
|
|
@ -154,6 +154,40 @@ class ContactForm(forms.ModelForm):
|
|||
for field_name in self.required:
|
||||
self.fields[field_name].required = True
|
||||
|
||||
# Set custom error messages
|
||||
self.fields["first_name"].error_messages = {"required": "Enter your first name / given name."}
|
||||
self.fields["last_name"].error_messages = {"required": "Enter your last name / family name."}
|
||||
self.fields["title"].error_messages = {
|
||||
"required": "Enter your title or role in your organization (e.g., Chief Information Officer)"
|
||||
}
|
||||
self.fields["email"].error_messages = {
|
||||
"required": "Enter your email address in the required format, like name@example.com."
|
||||
}
|
||||
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 your authorizing official."
|
||||
}
|
||||
self.fields["last_name"].error_messages = {
|
||||
"required": "Enter the last name / family name of your authorizing official."
|
||||
}
|
||||
self.fields["title"].error_messages = {
|
||||
"required": "Enter the title or role your authorizing official has in your \
|
||||
organization (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 your authorizing official."}
|
||||
|
||||
|
||||
class DomainSecurityEmailForm(forms.Form):
|
||||
"""Form for adding or editing a security email to a domain."""
|
||||
|
|
|
@ -37,6 +37,7 @@ from registrar.models.utility.contact_error import ContactError
|
|||
|
||||
from ..forms import (
|
||||
ContactForm,
|
||||
AuthorizingOfficialContactForm,
|
||||
DomainOrgNameAddressForm,
|
||||
DomainAddUserForm,
|
||||
DomainSecurityEmailForm,
|
||||
|
@ -186,7 +187,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."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue