Skip to content

Commit

Permalink
feat/add-error-messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPRobinson committed Dec 17, 2024
1 parent bd45a01 commit 55f62ec
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dataworkspace/dataworkspace/apps/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AddDatasetRequestForm(GOVUKDesignSystemForm):
attrs={"rows": 5},
extra_label_classes="govuk-!-static-margin-0",
),
error_messages={"required": "Please tell us about the data you want to add."},
error_messages={"required": "Enter information about the data you want to add"},
)


Expand All @@ -61,7 +61,7 @@ class CustomVisualisationReviewForm(GOVUKDesignSystemForm):
extra_label_classes="govuk-!-static-margin-0",
attrs={"rows": 5},
),
error_messages={"required": "Enter information about your visualisation."},
error_messages={"required": "Enter your visualisation's name"},
)


Expand All @@ -76,7 +76,7 @@ class SupportAnalysisDatasetForm(GOVUKDesignSystemForm):
label_is_heading=True,
attrs={"rows": 5},
),
error_messages={"required": "Please tell us what you need support with."},
error_messages={"required": "Enter details about the support or advice you need"},
)


Expand All @@ -98,7 +98,7 @@ class SupportTypes(models.TextChoices):
help_text="Please choose one of the options below for help.",
choices=SupportTypes.choices,
widget=ConditionalSupportTypeRadioWidget(heading="h2"),
error_messages={"required": "Please select the type of support you require."},
error_messages={"required": "Please select the type of support you require"},
)
message = GOVUKDesignSystemTextareaField(
required=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@
<a href="{% url 'support' %}" class="govuk-back-link">Back</a>
{% endblock %}
{% block content %}
{% if form.errors %}
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
<h2 class="govuk-error-summary__title" id="error-summary-title">
There is a problem
</h2>
<div class="govuk-error-summary__body">
<ul class="govuk-list govuk-error-summary__list">
{% for field, errors in form.errors.items %}
{% for error in errors %}
<li>
<a href="#id_{{ field }}">{{ error }}</a>
</li>
{% endfor %}
{% endfor %}
</ul>
</div>
</div>
{% endif %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">Add a new dataset</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@
<a href="{% url 'support' %}" class="govuk-back-link">Back</a>
{% endblock %}
{% block content %}
{% if form.errors %}
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
<h2 class="govuk-error-summary__title" id="error-summary-title">
There is a problem
</h2>
<div class="govuk-error-summary__body">
<ul class="govuk-list govuk-error-summary__list">
{% for field, errors in form.errors.items %}
{% for error in errors %}
<li>
<a href="#id_{{ field }}">{{ error }}</a>
</li>
{% endfor %}
{% endfor %}
</ul>
</div>
</div>
{% endif %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">Get your custom visualisation reviewed</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@
<a href="{% url 'support' %}" class="govuk-back-link">Back</a>
{% endblock %}
{% block content %}
{% if form.errors %}
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="govuk-error-summary">
<h2 class="govuk-error-summary__title" id="error-summary-title">
There is a problem
</h2>
<div class="govuk-error-summary__body">
<ul class="govuk-list govuk-error-summary__list">
{% for field, errors in form.errors.items %}
{% for error in errors %}
<li>
<a href="#id_{{ field }}">{{ error }}</a>
</li>
{% endfor %}
{% endfor %}
</ul>
</div>
</div>
{% endif %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">Get support with data analysis</h1>
Expand Down

0 comments on commit 55f62ec

Please sign in to comment.