Skip to content

Commit 399dd8e

Browse files
committed
Delete this commit. Demo for testing
Demo for testing that data in various shapes doesn't get overwritten. Next step: have tests to handle this.
1 parent 83efefe commit 399dd8e

File tree

3 files changed

+131
-4
lines changed

3 files changed

+131
-4
lines changed

app/data/session-data-defaults.js

+42-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,47 @@ Example usage:
1616
============================================================================
1717
1818
*/
19-
2019
module.exports = {
21-
22-
// Insert values here
23-
20+
// Example as used in current docs
21+
claimant: {
22+
field1: 'Example 1',
23+
field2: 'Example 2',
24+
field3: 'Example 3'
25+
},
26+
partner: {
27+
field1: 'Example 1',
28+
field2: 'Example 2',
29+
field3: 'Example 3'
30+
},
31+
myObject: {
32+
// Array of objects within object
33+
myArrayOfObjects: [
34+
{
35+
name: 'test1',
36+
address: 'test2'
37+
},
38+
{
39+
name: 'test3'
40+
}
41+
],
42+
// Simple array within object
43+
mySimpleArray: [
44+
'test4',
45+
'test5'
46+
],
47+
// Multi-level array within object
48+
myMultiLevelArray: [
49+
[
50+
['test6', 'test7'],
51+
'test8'
52+
]
53+
]
54+
},
55+
// Arrays within array
56+
myArray: [
57+
[
58+
'test9',
59+
['test10', 'test11']
60+
]
61+
]
2462
}
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{% extends "layout.html" %}
2+
3+
{% block pageTitle %}
4+
Example - Passing data
5+
{% endblock %}
6+
7+
{% block beforeContent %}
8+
{% include "includes/breadcrumb_examples.html" %}
9+
{% endblock %}
10+
11+
{% block content %}
12+
13+
<div class="govuk-grid-row">
14+
<div class="govuk-grid-column-two-thirds">
15+
16+
<form action="/docs/examples/pass-data/test2" method="post" class="form">
17+
18+
<div class="govuk-form-group">
19+
<h3 class="govuk-label-wrapper">
20+
Example as used in current docs
21+
</h3>
22+
<input class="govuk-input" id="registration-number" name="[claimant][field1]" value="{{ data['claimant']['field1'] }}" type="text">
23+
<h3 class="govuk-label-wrapper">
24+
Array of objects within object
25+
</h3>
26+
<input class="govuk-input" id="registration-number" name="[myObject][myArrayOfObjects][0][name]" value="{{ data['myObject']['myArrayOfObjects'][0]['name'] }}" type="text">
27+
<h3 class="govuk-label-wrapper">
28+
Simple array within object
29+
</h3>
30+
<input class="govuk-input" id="registration-number" name="[myObject][mySimpleArray][0]" value="{{ data['myObject']['mySimpleArray'][0] }}" type="text">
31+
<h3 class="govuk-label-wrapper">
32+
Multi-level array within object
33+
</h3>
34+
<input class="govuk-input" id="registration-number" name="[myObject][myMultiLevelArray][0][0][0]" value="{{ data['myObject']['myMultiLevelArray'][0][0][0] }}" type="text">
35+
<h3 class="govuk-label-wrapper">
36+
Arrays within array
37+
</h3>
38+
<input class="govuk-input" id="registration-number" name="[myArray][0][0]" value="{{ data['myArray'][0][0] }}" type="text">
39+
</div>
40+
41+
<button class="govuk-button">Continue</button>
42+
43+
</form>
44+
45+
</div>
46+
</div>
47+
{% endblock %}
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{% extends "layout.html" %}
2+
3+
{% block pageTitle %}
4+
Check your answers
5+
{% endblock %}
6+
7+
{% block content %}
8+
9+
<div class="govuk-grid-row">
10+
<div class="govuk-grid-column-two-thirds">
11+
12+
<h3>Example as used in current docs</h3>
13+
{{ data['claimant']['field1'] }}
14+
{{ data['claimant']['field2'] }}
15+
<br>
16+
<br>
17+
<h3>Array of objects within object</h3>
18+
{{ data['myObject']['myArrayOfObjects'][0]['name'] }}
19+
{{ data['myObject']['myArrayOfObjects'][0]['address'] }}
20+
{{ data['myObject']['myArrayOfObjects'][1]['name'] }}
21+
<br>
22+
<br>
23+
<h3>Simple array within object</h3>
24+
{{ data['myObject']['mySimpleArray'][0] }}
25+
{{ data['myObject']['mySimpleArray'][1] }}
26+
<br>
27+
<br>
28+
<h3>Multi-level array within object</h3>
29+
{{ data['myObject']['myMultiLevelArray'][0][0][0] }}
30+
{{ data['myObject']['myMultiLevelArray'][0][0][1] }}
31+
{{ data['myObject']['myMultiLevelArray'][0][1] }}
32+
<br>
33+
<br>
34+
<h3>Arrays within array</h3>
35+
{{ data['myArray'][0][0] }}
36+
{{ data['myArray'][0][1][0] }}
37+
{{ data['myArray'][0][1][1] }}
38+
</div>
39+
40+
</div>
41+
42+
{% endblock %}

0 commit comments

Comments
 (0)