From 9c1f73e512bd863e20ed4a4de3147e608ca4a804 Mon Sep 17 00:00:00 2001 From: "Paul D. Waite" Date: Wed, 13 Sep 2017 16:41:47 +0100 Subject: [PATCH] Added examples for simple single question form pages, with and without errors. See #543. --- app/routes.js | 44 ++++++++++++++++ ...ation_single_question_radio_h1_legend.html | 22 ++++++++ ...idation_single_question_text_h1_label.html | 22 ++++++++ app/views/guide_errors.html | 12 ++++- .../snippets/form_error_radio_h1_legend.html | 50 +++++++++++++++++++ .../snippets/form_error_text_h1_label.html | 38 ++++++++++++++ 6 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 app/views/examples/example_form_validation_single_question_radio_h1_legend.html create mode 100644 app/views/examples/example_form_validation_single_question_text_h1_label.html create mode 100644 app/views/snippets/form_error_radio_h1_legend.html create mode 100644 app/views/snippets/form_error_text_h1_label.html diff --git a/app/routes.js b/app/routes.js index ce62576c0..84332ec93 100755 --- a/app/routes.js +++ b/app/routes.js @@ -173,6 +173,50 @@ module.exports = { res.render('examples/example_form_validation_single_question_radio', { 'section': section, 'section_name': sectionName, 'page_name': pageName, 'personal_details': personalDetails, 'error': error }) }) + // Example page: Form validation + app.get('/errors/example-form-validation-single-question-radio-h1-legend', function (req, res) { + var section = 'errors' + var sectionName = 'Errors and validation' + var pageName = 'Example: Form validation - single question, page heading in legend' + res.render('examples/example_form_validation_single_question_radio_h1_legend', { 'section': section, 'section_name': sectionName, 'page_name': pageName }) + }) + + app.post('/errors/example-form-validation-single-question-radio-h1-legend', function (req, res) { + var section = 'errors' + var sectionName = 'Errors and validation' + var pageName = 'Example: Form validation - single question, page heading in legend' + var personalDetails = req.body.personalDetails + var error = false + if (!personalDetails) { + error = true + } else { + error = false + } + res.render('examples/example_form_validation_single_question_radio_h1_legend', { 'section': section, 'section_name': sectionName, 'page_name': pageName, 'personal_details': personalDetails, 'error': error }) + }) + + // Example page: Form validation + app.get('/errors/example-form-validation-single-question-text-h1-label', function (req, res) { + var section = 'errors' + var sectionName = 'Errors and validation' + var pageName = 'Example: Form validation - single question, labed in page heading' + res.render('examples/example_form_validation_single_question_text_h1_label', { 'section': section, 'section_name': sectionName, 'page_name': pageName }) + }) + + app.post('/errors/example-form-validation-single-question-text-h1-label', function (req, res) { + var section = 'errors' + var sectionName = 'Errors and validation' + var pageName = 'Example: Form validation - single question, label in page heading' + var personalDetails = req.body.personalDetails + var error = false + if (!personalDetails) { + error = true + } else { + error = false + } + res.render('examples/example_form_validation_single_question_text_h1_label', { 'section': section, 'section_name': sectionName, 'page_name': pageName, 'personal_details': personalDetails, 'error': error }) + }) + // Redirect examples from /examples/ to /section/example-name-of-example app.get('/examples/form-validation-single-question-radio', function (req, res) { res.redirect('/errors/example-form-validation-single-question-radio') diff --git a/app/views/examples/example_form_validation_single_question_radio_h1_legend.html b/app/views/examples/example_form_validation_single_question_radio_h1_legend.html new file mode 100644 index 000000000..b695ac00f --- /dev/null +++ b/app/views/examples/example_form_validation_single_question_radio_h1_legend.html @@ -0,0 +1,22 @@ +{% extends "layout_example.html" %} + +{% block page_title %}{% if error %}Error: {% endif %}Example: Form validation — Errors — GOV.UK elements{% endblock %} + +{% block content %} +
+ + {% include "includes/breadcrumb.html" %} + +
+
+ +
+ {% include "snippets/form_error_radio_h1_legend.html" %} +
+ + {% include "examples/_form_validation_implementation_advice.html" %} + +
+
+
+{% endblock %} diff --git a/app/views/examples/example_form_validation_single_question_text_h1_label.html b/app/views/examples/example_form_validation_single_question_text_h1_label.html new file mode 100644 index 000000000..816309af7 --- /dev/null +++ b/app/views/examples/example_form_validation_single_question_text_h1_label.html @@ -0,0 +1,22 @@ +{% extends "layout_example.html" %} + +{% block page_title %}{% if error %}Error: {% endif %}Example: Form validation — Errors — GOV.UK elements{% endblock %} + +{% block content %} +
+ + {% include "includes/breadcrumb.html" %} + +
+
+ +
+ {% include "snippets/form_error_text_h1_label.html" %} +
+ + {% include "examples/_form_validation_implementation_advice.html" %} + +
+
+
+{% endblock %} diff --git a/app/views/guide_errors.html b/app/views/guide_errors.html index 63758eec7..67c6eb9a6 100755 --- a/app/views/guide_errors.html +++ b/app/views/guide_errors.html @@ -106,9 +106,19 @@

Examples