-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "None of these" JavaScript behaviour to checkboxes
See original at alphagov/govuk-frontend#2151
- Loading branch information
1 parent
7dc973d
commit 4f91d11
Showing
6 changed files
with
325 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{% set html_style = 'background-color: #f0f4f5;' %} | ||
{% set title = 'Checkboxes with conditional content' %} | ||
{% from 'components/checkboxes/macro.njk' import checkboxes %} | ||
{% from 'components/input/macro.njk' import input %} | ||
{% extends 'layout.njk' %} | ||
|
||
{% set emailHtml %} | ||
{{ input({ | ||
id: "email", | ||
name: "email", | ||
classes: "nhsuk-u-width-two-thirds", | ||
label: { | ||
text: "Email address" | ||
} | ||
}) }} | ||
{% endset -%} | ||
|
||
{% set phoneHtml %} | ||
{{ input({ | ||
id: "phone", | ||
name: "phone", | ||
classes: "nhsuk-u-width-two-thirds", | ||
label: { | ||
text: "Phone number" | ||
} | ||
}) }} | ||
{% endset -%} | ||
|
||
{% set mobileHtml %} | ||
{{ input({ | ||
id: "mobile", | ||
name: "mobile", | ||
classes: "nhsuk-u-width-two-thirds", | ||
label: { | ||
text: "Mobile phone number" | ||
} | ||
}) }} | ||
{% endset -%} | ||
|
||
{% block body %} | ||
|
||
<div class="nhsuk-width-container"> | ||
<main class="nhsuk-main-wrapper" id="maincontent"> | ||
|
||
<div class="nhsuk-grid-row"> | ||
<div class="nhsuk-grid-column-two-thirds"> | ||
{{ checkboxes({ | ||
"idPrefix": "contact", | ||
"name": "contact", | ||
"fieldset": { | ||
"legend": { | ||
"text": "How would you prefer to be contacted?", | ||
"classes": "nhsuk-fieldset__legend--l", | ||
"isPageHeading": "true" | ||
} | ||
}, | ||
"hint": { | ||
"text": "Select all options that are relevant to you." | ||
}, | ||
"items": [ | ||
{ | ||
"value": "email", | ||
"text": "Email", | ||
"conditional": { | ||
"html": emailHtml | ||
} | ||
}, | ||
{ | ||
"value": "phone", | ||
"text": "Phone", | ||
"conditional": { | ||
"html": phoneHtml | ||
} | ||
}, | ||
{ | ||
"value": "text", | ||
"text": "Text message", | ||
"conditional": { | ||
"html": mobileHtml | ||
} | ||
}, | ||
{ | ||
divider: "or" | ||
}, | ||
{ | ||
value: "none", | ||
text: "None of the above", | ||
behaviour: "exclusive" | ||
} | ||
] | ||
}) }} | ||
</div> | ||
</div> | ||
|
||
</main> | ||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters