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."""
|
"""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.)"))
|
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"
|
field_name = "has_other_contacts"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -239,6 +239,10 @@ class BaseYesNoForm(RegistrarForm):
|
||||||
# Default form choice mapping. Default is suitable for most cases.
|
# Default form choice mapping. Default is suitable for most cases.
|
||||||
form_choices = ((True, "Yes"), (False, "No"))
|
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):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Extend the initialization of the form from RegistrarForm __init__"""
|
"""Extend the initialization of the form from RegistrarForm __init__"""
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
@ -256,7 +260,11 @@ class BaseYesNoForm(RegistrarForm):
|
||||||
coerce=lambda x: x.lower() == "true" if x is not None else None,
|
coerce=lambda x: x.lower() == "true" if x is not None else None,
|
||||||
choices=self.form_choices,
|
choices=self.form_choices,
|
||||||
initial=self.get_initial_value(),
|
initial=self.get_initial_value(),
|
||||||
widget=forms.RadioSelect,
|
widget=forms.RadioSelect(
|
||||||
|
attrs={
|
||||||
|
"aria-label": self.aria_label
|
||||||
|
}
|
||||||
|
),
|
||||||
error_messages={
|
error_messages={
|
||||||
"required": self.required_error_message,
|
"required": self.required_error_message,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,19 +1,25 @@
|
||||||
<{{ label_tag }}
|
<!-- Exclude extraneous legend from radio elements -->
|
||||||
class="{% if label_classes %} {{ label_classes }}{% endif %}{% if label_tag == 'legend' %} {{ legend_classes }}{% endif %}"
|
{% if not type == "radio" and not label_tag == "legend" %}
|
||||||
{% if not field.use_fieldset %}for="{{ widget.attrs.id }}"{% endif %}
|
<{{ label_tag }}
|
||||||
>
|
class="{% if label_classes %} {{ label_classes }}{% endif %}{% if label_tag == 'legend' %} {{ legend_classes }}{% endif %}"
|
||||||
{% if span_for_text %}
|
{% if not field.use_fieldset %}for="{{ widget.attrs.id }}"{% endif %}
|
||||||
<span>{{ field.label }}</span>
|
>
|
||||||
{% else %}
|
{% endif %}
|
||||||
{{ field.label }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if widget.attrs.required %}
|
{% if span_for_text %}
|
||||||
<!--Don't add asterisk to one-field forms -->
|
<span>{{ field.label }}</span>
|
||||||
{% 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 %}
|
{% else %}
|
||||||
<abbr class="usa-hint usa-hint--required" title="required">*</abbr>
|
{{ field.label }}
|
||||||
{% endif %}
|
{% 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 %}
|
{% endif %}
|
||||||
|
|
||||||
{# this is the input field, itself #}
|
{# this is the input field, itself #}
|
||||||
{% include widget.template_name %}
|
{% with aria_label=aria_label %}
|
||||||
|
{% include widget.template_name %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% if append_gov %}
|
{% if append_gov %}
|
||||||
<span class="padding-top-05 padding-left-2px">.gov </span>
|
<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": ...}}
|
) # -> {"widget": {"name": ...}}
|
||||||
|
|
||||||
context["widget"] = widget["widget"]
|
context["widget"] = widget["widget"]
|
||||||
|
print("context: ", context)
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue