diff --git a/src/registrar/forms/domain_request_wizard.py b/src/registrar/forms/domain_request_wizard.py index a619aec26..5d8f23057 100644 --- a/src/registrar/forms/domain_request_wizard.py +++ b/src/registrar/forms/domain_request_wizard.py @@ -544,6 +544,7 @@ class OtherContactsYesNoForm(BaseYesNoForm): """The yes/no field for the OtherContacts form.""" form_choices = ((True, "Yes, I can name other employees."), (False, "No. (We’ll ask you to explain why.)")) + title_label = "Are there other employees who can help verify your request?" field_name = "has_other_contacts" @property diff --git a/src/registrar/forms/utility/wizard_form_helper.py b/src/registrar/forms/utility/wizard_form_helper.py index eedf5839b..22c70b010 100644 --- a/src/registrar/forms/utility/wizard_form_helper.py +++ b/src/registrar/forms/utility/wizard_form_helper.py @@ -239,6 +239,10 @@ class BaseYesNoForm(RegistrarForm): # Default form choice mapping. Default is suitable for most cases. form_choices = ((True, "Yes"), (False, "No")) + # Option to append question to aria label for screenreader accessibility. + # Not added by default. + aria_label = "" + def __init__(self, *args, **kwargs): """Extend the initialization of the form from RegistrarForm __init__""" super().__init__(*args, **kwargs) @@ -256,7 +260,11 @@ class BaseYesNoForm(RegistrarForm): coerce=lambda x: x.lower() == "true" if x is not None else None, choices=self.form_choices, initial=self.get_initial_value(), - widget=forms.RadioSelect, + widget=forms.RadioSelect( + attrs={ + "aria-label": self.aria_label + } + ), error_messages={ "required": self.required_error_message, }, diff --git a/src/registrar/templates/django/forms/label.html b/src/registrar/templates/django/forms/label.html index 545ccf781..e4d7842fa 100644 --- a/src/registrar/templates/django/forms/label.html +++ b/src/registrar/templates/django/forms/label.html @@ -1,19 +1,25 @@ -<{{ label_tag }} - class="{% if label_classes %} {{ label_classes }}{% endif %}{% if label_tag == 'legend' %} {{ legend_classes }}{% endif %}" - {% if not field.use_fieldset %}for="{{ widget.attrs.id }}"{% endif %} -> - {% if span_for_text %} - {{ field.label }} - {% else %} - {{ field.label }} - {% endif %} + +{% if not type == "radio" and not label_tag == "legend" %} + <{{ label_tag }} + class="{% if label_classes %} {{ label_classes }}{% endif %}{% if label_tag == 'legend' %} {{ legend_classes }}{% endif %}" + {% if not field.use_fieldset %}for="{{ widget.attrs.id }}"{% endif %} + > +{% endif %} - {% if widget.attrs.required %} - - {% if field.label == "Is your organization an election office?" or field.label == "What .gov domain do you want?" or field.label == "I read and agree to the requirements for operating a .gov domain." or field.label == "Please explain why there are no other employees from your organization we can contact to help us assess your eligibility for a .gov domain." %} + {% if span_for_text %} + {{ field.label }} {% else %} - * + {{ field.label }} {% endif %} - {% endif %} - + {% if widget.attrs.required %} + + {% if field.label == "Is your organization an election office?" or field.label == "What .gov domain do you want?" or field.label == "I read and agree to the requirements for operating a .gov domain." or field.label == "Please explain why there are no other employees from your organization we can contact to help us assess your eligibility for a .gov domain." %} + {% else %} + * + {% endif %} + {% endif %} + +{% if not type == "radio" and not label_tag == "legend" %} + +{% endif %} diff --git a/src/registrar/templates/includes/input_with_errors.html b/src/registrar/templates/includes/input_with_errors.html index d1e53968e..d239954a0 100644 --- a/src/registrar/templates/includes/input_with_errors.html +++ b/src/registrar/templates/includes/input_with_errors.html @@ -68,7 +68,11 @@ error messages, if necessary. {% endif %} {# this is the input field, itself #} - {% include widget.template_name %} + {% with aria_label=aria_label %} + {% include widget.template_name %} + {% endwith %} + + {% if append_gov %} .gov diff --git a/src/registrar/templatetags/field_helpers.py b/src/registrar/templatetags/field_helpers.py index 8a80a75b9..d2bca13fb 100644 --- a/src/registrar/templatetags/field_helpers.py +++ b/src/registrar/templatetags/field_helpers.py @@ -169,5 +169,6 @@ def input_with_errors(context, field=None): # noqa: C901 ) # -> {"widget": {"name": ...}} context["widget"] = widget["widget"] + print("context: ", context) return context