Skip to content

Commit

Permalink
Change class names for validation errors in html
Browse files Browse the repository at this point in the history
Implements the class name changes detailed in:
alphagov/govuk_elements#405
  • Loading branch information
quis committed Apr 10, 2017
1 parent 87c81c9 commit 8d5af47
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
2 changes: 0 additions & 2 deletions app/assets/javascripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ $(() => $("time.timeago").timeago());

$(() => GOVUK.modules.start());

$(() => new GOVUK.SelectionButtons('.block-label input'));

$(() => $('.error-message').eq(0).parent('label').next('input').trigger('focus'));

$(() => $('.banner-dangerous').eq(0).trigger('focus'));
2 changes: 1 addition & 1 deletion app/assets/stylesheets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $path: '/static/images/';
@import 'elements/elements-typography';
@import 'elements/forms';
@import 'elements/forms/form-validation';
@import 'elements/forms/form-block-labels';
@import 'elements/forms/form-multiple-choice';
@import 'elements/forms/form-validation';
@import 'elements/icons';
@import 'elements/layout';
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/file-upload.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% macro file_upload(field, button_text="Choose file", alternate_link=None, alternate_link_text=None) %}
<form method="post" enctype="multipart/form-data" class="{% if field.errors %}error{% endif %}" data-module="file-upload">
<form method="post" enctype="multipart/form-data" class="{% if field.errors %}form-group-error{% endif %}" data-module="file-upload">
<label class="file-upload-label" for="{{ field.name }}">
<span class="visually-hidden">{{ field.label.text }}</span>
{% if hint %}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/list-entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% if error %}
<div class="validation-wrapper">
{% endif %}
<fieldset class="form-group{% if field.errors %} error{% endif %}" id="{{ field.name }}">
<fieldset class="form-group{% if field.errors %} form-group-error{% endif %}" id="{{ field.name }}">
<legend>
<span class="form-label">
{{ field.label.text }}
Expand Down
6 changes: 3 additions & 3 deletions app/templates/components/radios.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
disable=[],
option_hints={}
) %}
<div class="form-group {% if field.errors %} error{% endif %}">
<div class="form-group {% if field.errors %} form-group-error{% endif %}">
<fieldset>
<legend class="form-label">
{{ field.label.text|safe }}
Expand Down Expand Up @@ -45,7 +45,7 @@
hint=None,
wrapping_class='form-group'
) %}
<div class="{{ wrapping_class }} {% if field.errors %} error{% endif %}">
<div class="{{ wrapping_class }} {% if field.errors %} form-group-error{% endif %}">
<fieldset>
<legend class="form-label">
{{ field.label.text }}
Expand Down Expand Up @@ -81,7 +81,7 @@
hint=None,
branding_dict={}
) %}
<div class="form-group {% if field.errors %} error{% endif %}">
<div class="form-group {% if field.errors %} form-group-error{% endif %}">
<fieldset>
<legend class="form-label">
{{ field.label.text }}
Expand Down
18 changes: 14 additions & 4 deletions app/templates/components/textbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
safe_error_message=False,
rows=8
) %}
<div class="form-group{% if field.errors %} error{% endif %}" {% if autofocus %}data-module="autofocus"{% endif %}>
<div class="form-group{% if field.errors %} form-group-error{% endif %}" {% if autofocus %}data-module="autofocus"{% endif %}>
<label class="form-label" for="{{ field.name }}">
{% if label %}
{{ label }}
Expand All @@ -29,10 +29,20 @@
</span>
{% endif %}
</label>
{%
if highlight_tags
%}
{% set field_class = 'form-control-{} textbox-highlight-textbox'.format(width) %}
{% else %}
{% set field_class = 'form-control-{} {}'.format(width, 'textbox-right-aligned' if suffix else '') %}
{% endif %}
{%
set field_class = 'form-control ' + field_class + (
' form-control-error' if field.errors else ''
)
%}
{{ field(**{
'class':
'form-control form-control-{} textbox-highlight-textbox'.format(width) if highlight_tags else
'form-control form-control-{} {}'.format(width, 'textbox-right-aligned' if suffix else ''),
'class': field_class,
'data-module': 'highlight-tags' if highlight_tags else '',
'rows': rows|string
}) }}
Expand Down

0 comments on commit 8d5af47

Please sign in to comment.