diff --git a/src/registrar/forms/utility/wizard_form_helper.py b/src/registrar/forms/utility/wizard_form_helper.py index 22c70b010..d48f7af64 100644 --- a/src/registrar/forms/utility/wizard_form_helper.py +++ b/src/registrar/forms/utility/wizard_form_helper.py @@ -241,7 +241,8 @@ class BaseYesNoForm(RegistrarForm): # Option to append question to aria label for screenreader accessibility. # Not added by default. - aria_label = "" + title_label = "" + aria_label = title_label.join("") def __init__(self, *args, **kwargs): """Extend the initialization of the form from RegistrarForm __init__""" @@ -262,7 +263,7 @@ class BaseYesNoForm(RegistrarForm): initial=self.get_initial_value(), widget=forms.RadioSelect( attrs={ - "aria-label": self.aria_label + # "aria-label": self.title_label } ), error_messages={ diff --git a/src/registrar/templates/django/forms/label.html b/src/registrar/templates/django/forms/label.html index e4d7842fa..eb9604dec 100644 --- a/src/registrar/templates/django/forms/label.html +++ b/src/registrar/templates/django/forms/label.html @@ -1,25 +1,24 @@ -{% 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 %} - +<{{ 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 legend_label %} +

{{ legend_label }}

+ {% else %} {% 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." %} + {% 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." or field.label == "Has other contacts" %} {% else %} * {% endif %} {% endif %} -{% if not type == "radio" and not label_tag == "legend" %} - -{% endif %} + diff --git a/src/registrar/templates/domain_request_other_contacts.html b/src/registrar/templates/domain_request_other_contacts.html index 72e4abd8b..93fafe872 100644 --- a/src/registrar/templates/domain_request_other_contacts.html +++ b/src/registrar/templates/domain_request_other_contacts.html @@ -17,17 +17,12 @@ {% endblock %} {% block form_fields %} -
- -

Are there other employees who can help verify your request?

-
- - {% with add_class="usa-radio__input--tile" add_legend_class="usa-sr-only" %} +
+ {% with add_class="usa-radio__input--tile" add_legend_label="Are there other employees who can help verify your request?" %} {% input_with_errors forms.0.has_other_contacts %} {% endwith %} {# forms.0 is a small yes/no form that toggles the visibility of "other contact" formset #} - -
+
{% include "includes/required_fields.html" %} diff --git a/src/registrar/templatetags/field_helpers.py b/src/registrar/templatetags/field_helpers.py index d2bca13fb..31ceb1072 100644 --- a/src/registrar/templatetags/field_helpers.py +++ b/src/registrar/templatetags/field_helpers.py @@ -57,6 +57,7 @@ def input_with_errors(context, field=None): # noqa: C901 legend_classes = [] group_classes = [] aria_labels = [] + legend_labels = [] # this will be converted to an attribute string described_by = [] @@ -90,6 +91,8 @@ def input_with_errors(context, field=None): # noqa: C901 label_classes.append(value) elif key == "add_legend_class": legend_classes.append(value) + elif key == "add_legend_label": + legend_labels.append(value) elif key == "add_group_class": group_classes.append(value) @@ -149,6 +152,9 @@ def input_with_errors(context, field=None): # noqa: C901 if legend_classes: context["legend_classes"] = " ".join(legend_classes) + if legend_labels: + context["legend_label"] = " ".join(legend_labels) + if group_classes: context["group_classes"] = " ".join(group_classes)