-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDefault.cshtml
More file actions
135 lines (124 loc) · 5.92 KB
/
Default.cshtml
File metadata and controls
135 lines (124 loc) · 5.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
@using NHSUKViewComponents.Web.Extensions
@using NHSUKViewComponents.Web.ViewModels
@model RadiosViewModel
@{
int counter = 0;
}
<div class="nhsuk-form-group @(Model.HasError ? "nhsuk-form-group--error" : "")">
<fieldset class="nhsuk-fieldset" aria-describedby="@(!string.IsNullOrEmpty(Model.HintText) ? $"{Model.Label.RemoveWhitespace()}-hint" : string.Empty)">
<legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
@if (Model.IsPageHeading.GetValueOrDefault() == true)
{
<h1>
@Model.Label
</h1>
}
else
{
@Model.Label
}
</legend>
@if (Model.HintText != null)
{
<div class="nhsuk-hint" id="@Model.Label.RemoveWhitespace()-hint">
@Html.Raw(Model.HintText)
</div>
}
@if (Model.HasError)
{
<div id="@Model.AspFor-error" class="nhsuk-u-padding-top-1 nhsuk-u-padding-bottom-3">
@foreach (var errorMessage in Model.ErrorMessages)
{
<span class="error-message--margin-bottom-1 nhsuk-error-message">
<span class="nhsuk-u-visually-hidden">Error:</span> @errorMessage
</span>
}
</div>
}
@if (Model.Required && !Model.HasError)
{
<div data-valmsg-for="@Model.AspFor" data-valmsg-replace="true" class="error-message--margin-bottom-1 nhsuk-error-message field-validation-valid nhsuk-u-padding-top-1 nhsuk-u-padding-bottom-3">
</div>
}
<div class="nhsuk-radios">
@foreach (var (radio, index) in Model.Radios.Select((r, i) => (r, i)))
{
counter = index;
var radioId = $"{radio.Value}-{index}";
if (!string.IsNullOrWhiteSpace(Model.Class))
{
<div class="@Model.Class">
<div class="nhsuk-radios__item">
<input class="nhsuk-radios__input"
id="@radioId"
name="@Model.AspFor"
type="radio"
value="@radio.Value"
aria-describedby="@(!string.IsNullOrEmpty(radio.HintText) ? $"{radio.Value}-item-hint" : string.Empty)"
data-val-required="@(Model.Required ? Model.RequiredClientSideErrorMessage : "")"
data-val="@(Model.Required ? "true" : "false")"
@(radio.Selected ? "checked" : string.Empty) />
<label class="nhsuk-label nhsuk-radios__label" for="@radioId">
@radio.Label
</label>
@if (radio.HintText != null)
{
<div class="nhsuk-hint nhsuk-radios__hint" id="@radio.Value-item-hint">
@radio.HintText
</div>
}
</div>
</div>
}
else
{
<div class="nhsuk-radios__item">
<input class="nhsuk-radios__input"
id="@radioId"
name="@Model.AspFor"
type="radio"
value="@radio.Value"
aria-describedby="@(!string.IsNullOrEmpty(radio.HintText) ? $"{radio.Value}-item-hint" : string.Empty)"
data-val-required="@(Model.Required ? Model.RequiredClientSideErrorMessage : "")"
data-val="@(Model.Required ? "true" : "false")"
@(radio.Selected ? "checked" : string.Empty) />
<label class="nhsuk-label nhsuk-radios__label" for="@radioId">
@radio.Label
</label>
@if (radio.HintText != null)
{
<div class="nhsuk-hint nhsuk-radios__hint" id="@radio.Value-item-hint">
@radio.HintText
</div>
}
</div>
}
}
@if (Model.OptionalRadio != null)
{
<div class="nhsuk-radios__divider nhsuk-u-padding-left-2">or</div>
var radioId = $"{Model.OptionalRadio.Value}-{++counter}";
<div class="nhsuk-radios__item">
<input class="nhsuk-radios__input"
id="@radioId"
name="@Model.AspFor"
type="radio"
value="@Model.OptionalRadio.Value"
aria-describedby="@(!string.IsNullOrEmpty(Model.OptionalRadio.HintText) ? $"{Model.OptionalRadio.Value}-item-hint" : string.Empty)"
data-val-required="@(Model.Required ? Model.RequiredClientSideErrorMessage : "")"
data-val="@(Model.Required ? "true" : "false")"
@(Model.OptionalRadio.Selected ? "checked" : string.Empty) />
<label class="nhsuk-label nhsuk-radios__label" for="@radioId">
@Model.OptionalRadio.Label
</label>
@if (Model.OptionalRadio.HintText != null)
{
<div class="nhsuk-hint nhsuk-radios__hint" id="@Model.OptionalRadio.Value-item-hint">
@Model.OptionalRadio.HintText
</div>
}
</div>
}
</div>
</fieldset>
</div>