mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-30 22:46:30 +02:00
Remove unused legends from radio groups
This commit is contained in:
parent
f918720383
commit
e76571eb50
5 changed files with 37 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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 %}
|
||||
<span>{{ field.label }}</span>
|
||||
{% else %}
|
||||
{{ field.label }}
|
||||
{% endif %}
|
||||
<!-- Exclude extraneous legend from radio elements -->
|
||||
{% 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 %}
|
||||
<!--Don't add asterisk to one-field forms -->
|
||||
{% 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 %}
|
||||
<span>{{ field.label }}</span>
|
||||
{% else %}
|
||||
<abbr class="usa-hint usa-hint--required" title="required">*</abbr>
|
||||
{{ field.label }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
</{{ label_tag }}>
|
||||
{% if widget.attrs.required %}
|
||||
<!--Don't add asterisk to one-field forms -->
|
||||
{% 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 %}
|
||||
<abbr class="usa-hint usa-hint--required" title="required">*</abbr>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if not type == "radio" and not label_tag == "legend" %}
|
||||
</{{ label_tag }}>
|
||||
{% endif %}
|
||||
|
|
|
@ -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 %}
|
||||
<span class="padding-top-05 padding-left-2px">.gov </span>
|
||||
|
|
|
@ -169,5 +169,6 @@ def input_with_errors(context, field=None): # noqa: C901
|
|||
) # -> {"widget": {"name": ...}}
|
||||
|
||||
context["widget"] = widget["widget"]
|
||||
print("context: ", context)
|
||||
|
||||
return context
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue