Merge pull request #426 from cisagov/nmb/trim-field-labels

Remove field labels and change required text
This commit is contained in:
Neil MartinsenBurrell 2023-02-28 13:27:55 -06:00 committed by GitHub
commit 22eb49c004
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 68 additions and 17 deletions

View file

@ -5,6 +5,10 @@
<p>Is there anything else we should know about your domain request?</p> <p>Is there anything else we should know about your domain request?</p>
{% endblock %} {% endblock %}
{% block form_required_fields_help_text %}
{# commented out so it does not appear on this page #}
{% endblock %}
{% block form_fields %} {% block form_fields %}
{% with add_label_class="usa-sr-only" attr_maxlength=500 %} {% with add_label_class="usa-sr-only" attr_maxlength=500 %}

View file

@ -2,16 +2,21 @@
{% load static field_helpers %} {% load static field_helpers %}
{% block form_instructions %} {% block form_instructions %}
<p>Enter your organizations public website, if you have one. For example, <p>Enter your organizations current public website, if you have one. For example,
www.city.com.</p> www.city.com.</p>
{% endblock %} {% endblock %}
{% block form_required_fields_help_text %}
{# empty this block so it doesn't show on this page #}
{% endblock %}
{% block form_fields %} {% block form_fields %}
{{ forms.0.management_form }} {{ forms.0.management_form }}
{% for form in forms.0 %} {% for form in forms.0 %}
{% with add_label_class="usa-sr-only" %}
{% input_with_errors form.website %} {% input_with_errors form.website %}
{% endwith %}
{% endfor %} {% endfor %}
<button type="submit" name="submit_button" value="save" class="usa-button usa-button--unstyled"> <button type="submit" name="submit_button" value="save" class="usa-button usa-button--unstyled">

View file

@ -27,13 +27,18 @@
{% endblock %} {% endblock %}
{% block form_required_fields_help_text %}
{# empty this block so it doesn't show on this page #}
{% endblock %}
{% block form_fields %} {% block form_fields %}
{{ forms.0.management_form }} {{ forms.0.management_form }}
<fieldset class="usa-fieldset"> <fieldset class="usa-fieldset">
<legend> <legend>
<h2>What .gov domain do you want?</h2> <h2>What .gov domain do you want? <abbr class="usa-hint usa-hint--required" title="required">*</abbr></h2>
</legend> </legend>
<p id="domain_instructions">After you enter your domain, well make sure its <p id="domain_instructions">After you enter your domain, well make sure its
@ -41,9 +46,11 @@
these initial checks, well verify that it meets all of our requirements once you these initial checks, well verify that it meets all of our requirements once you
complete and submit the rest of this form.</p> complete and submit the rest of this form.</p>
<p class="text-semibold"><abbr class="usa-hint usa-hint--required" title="required">*</abbr> This question is required.</p>
{% with attr_aria_describedby="domain_instructions domain_instructions2" %} {% with attr_aria_describedby="domain_instructions domain_instructions2" %}
{# attr_validate / validate="domain" invokes code in get-gov.js #} {# attr_validate / validate="domain" invokes code in get-gov.js #}
{% with www_gov=True attr_validate="domain" %} {% with www_gov=True attr_validate="domain" add_label_class="usa-sr-only" %}
{% input_with_errors forms.0.requested_domain %} {% input_with_errors forms.0.requested_domain %}
{% endwith %} {% endwith %}
{% endwith %} {% endwith %}

View file

@ -3,14 +3,18 @@
{% block form_instructions %} {% block form_instructions %}
<h2 class="margin-bottom-05"> <h2 class="margin-bottom-05">
Is your organization an election office? Is your organization an election office? <abbr class="usa-hint usa-hint--required" title="required">*</abbr>
</h2> </h2>
<p>Answer “yes” if the primary purpose of your organization is to manage elections.</p>
<p>Answer “yes” if the primary purpose of your organization is to manage elections.</p>
{% endblock %} {% endblock %}
{% block form_required_fields_help_text %}
<p class="text-semibold"><abbr class="usa-hint usa-hint--required" title="required">*</abbr> This question is required.</p>
{% endblock %}
{% block form_fields %} {% block form_fields %}
{% with add_class="usa-radio__input--tile" %} {% with add_class="usa-radio__input--tile" add_legend_class="usa-sr-only" %}
{% input_with_errors forms.0.is_election_board %} {% input_with_errors forms.0.is_election_board %}
{% endwith %} {% endwith %}
{% endblock %} {% endblock %}

View file

@ -3,13 +3,17 @@
{% block form_instructions %} {% block form_instructions %}
<h2 class="margin-bottom-05"> <h2 class="margin-bottom-05">
Which federal branch is your organization in? Which federal branch is your organization in? <abbr class="usa-hint usa-hint--required" title="required">*</abbr>
</h2> </h2>
{% endblock %} {% endblock %}
{% block form_required_fields_help_text %}
<p class="text-semibold"><abbr class="usa-hint usa-hint--required" title="required">*</abbr> This question is required.</p>
{% endblock %}
{% block form_fields %} {% block form_fields %}
{% with add_class="usa-radio__input--tile" %} {% with add_class="usa-radio__input--tile" add_legend_class="usa-sr-only" %}
{% input_with_errors forms.0.federal_type %} {% input_with_errors forms.0.federal_type %}
{% endwith %} {% endwith %}
{% endblock %} {% endblock %}

View file

@ -3,13 +3,18 @@
{% block form_instructions %} {% block form_instructions %}
<h2 class="margin-bottom-05"> <h2 class="margin-bottom-05">
What kind of U.S.-based government organization do you represent? What kind of U.S.-based government organization do you represent? <abbr class="usa-hint usa-hint--required" title="required">*</abbr>
</h2> </h2>
{% endblock %}
{% block form_required_fields_help_text %}
<p class="text-semibold"><abbr class="usa-hint usa-hint--required" title="required">*</abbr> This question is required.</p>
{% endblock %} {% endblock %}
{% block form_fields %} {% block form_fields %}
{% with add_class="usa-radio__input--tile" %} {% with add_class="usa-radio__input--tile" add_legend_class="usa-sr-only" %}
{% input_with_errors forms.0.organization_type %} {% input_with_errors forms.0.organization_type %}
{% endwith %} {% endwith %}
{% endblock %} {% endblock %}

View file

@ -7,6 +7,11 @@
<p>Well email these contacts to let them know that you made this request.</p> <p>Well email these contacts to let them know that you made this request.</p>
{% endblock %} {% endblock %}
{% block form_required_fields_help_text %}
{# there are no required fields on this page so don't show this #}
{% endblock %}
{% block form_fields %} {% block form_fields %}
{{ forms.0.management_form }} {{ forms.0.management_form }}

View file

@ -9,11 +9,17 @@ domain name or for mainly internal use.</p>
Who is your intended audience? Will you use it for a website and/or email? Are you moving Who is your intended audience? Will you use it for a website and/or email? Are you moving
your website from another top-level domain (like .com or .org)? your website from another top-level domain (like .com or .org)?
Read about <a href="{% url 'todo' %}">activities that are prohibited on .gov domains.</a></p> Read about <a href="{% url 'todo' %}">activities that are prohibited on .gov domains.</a></p>
{% endblock %} {% endblock %}
{% block form_required_fields_help_text %}
<p class="text-semibold"><abbr class="usa-hint usa-hint--required" title="required">*</abbr> This question is required.</p>
{% endblock %}
{% block form_fields %} {% block form_fields %}
{% with attr_maxlength=500 %} {% with attr_maxlength=500 add_label_class="usa-sr-only" %}
{% input_with_errors forms.0.purpose %} {% input_with_errors forms.0.purpose %}
{% endwith %} {% endwith %}
{% endblock %} {% endblock %}

View file

@ -1,6 +1,10 @@
{% extends 'application_form.html' %} {% extends 'application_form.html' %}
{% load static url_helpers %} {% load static url_helpers %}
{% block form_required_fields_help_text %}
{# there are no required fields on this page so don't show this #}
{% endblock %}
{% block form_fields %} {% block form_fields %}
{% for step in steps.all|slice:":-1" %} {% for step in steps.all|slice:":-1" %}
<section class="review__step"> <section class="review__step">

View file

@ -1,5 +1,5 @@
<{{ label_tag }} <{{ label_tag }}
class="{% if label_classes %} {{ label_classes }}{% endif %}" 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 not field.use_fieldset %}for="{{ widget.attrs.id }}"{% endif %}
> >
{{ field.label }} {{ field.label }}

View file

@ -21,6 +21,7 @@ def input_with_errors(context, field=None): # noqa: C901
add_error_class: like `add_class` but only if field.errors is not empty add_error_class: like `add_class` but only if field.errors is not empty
add_required_class: like `add_class` but only if field is required add_required_class: like `add_class` but only if field is required
add_label_class: append to input element's label's `class` attribute add_label_class: append to input element's label's `class` attribute
add_legend_class: append to input element's legend's `class` attribute
add_group_class: append to input element's surrounding tag's `class` attribute add_group_class: append to input element's surrounding tag's `class` attribute
attr_* - adds or replaces any single html attribute for the input attr_* - adds or replaces any single html attribute for the input
add_error_attr_* - like `attr_*` but only if field.errors is not empty add_error_attr_* - like `attr_*` but only if field.errors is not empty
@ -50,6 +51,7 @@ def input_with_errors(context, field=None): # noqa: C901
# these will be converted to CSS strings # these will be converted to CSS strings
classes = [] classes = []
label_classes = [] label_classes = []
legend_classes = []
group_classes = [] group_classes = []
# this will be converted to an attribute string # this will be converted to an attribute string
@ -82,6 +84,8 @@ def input_with_errors(context, field=None): # noqa: C901
elif key == "add_label_class": elif key == "add_label_class":
label_classes.append(value) label_classes.append(value)
elif key == "add_legend_class":
legend_classes.append(value)
elif key == "add_group_class": elif key == "add_group_class":
group_classes.append(value) group_classes.append(value)
@ -129,6 +133,9 @@ def input_with_errors(context, field=None): # noqa: C901
if label_classes: if label_classes:
context["label_classes"] = " ".join(label_classes) context["label_classes"] = " ".join(label_classes)
if legend_classes:
context["legend_classes"] = " ".join(legend_classes)
if group_classes: if group_classes:
context["group_classes"] = " ".join(group_classes) context["group_classes"] = " ".join(group_classes)