-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1497 from alphagov/radio-trigger-setattributes
Users can now conditionally reveal content on pages with multiple grouped radios
- Loading branch information
Showing
4 changed files
with
225 additions
and
11 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
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,176 @@ | ||
{% extends "layout.njk" %} | ||
|
||
{% from "back-link/macro.njk" import govukBackLink %} | ||
{% from "button/macro.njk" import govukButton %} | ||
{% from "radios/macro.njk" import govukRadios %} | ||
|
||
{% block beforeContent %} | ||
{{ govukBackLink({ | ||
"href": "/" | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h1 class="govuk-heading-xl">Multiple radio groups</h1> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-one-half"> | ||
<form method="get" novalidate> | ||
<fieldset class="govuk-fieldset"> | ||
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l"> | ||
<h2 class="govuk-fieldset__heading"> | ||
What is your favourite colour? | ||
</h2> | ||
</legend> | ||
<h3 class="govuk-heading-m">Warm colours</h3> | ||
{{ govukRadios({ | ||
idPrefix: "warm", | ||
name: "colour", | ||
items: [ | ||
{ | ||
value: "red", | ||
text: "Red", | ||
conditional: { | ||
html: '<p class="govuk-body">Nice choice, I like red too.</p>' | ||
} | ||
}, | ||
{ | ||
value: "orange", | ||
text: "Orange", | ||
conditional: { | ||
html: '<p class="govuk-body">Nice choice, I like orange too.</p>' | ||
} | ||
} | ||
] | ||
}) }} | ||
|
||
<h3 class="govuk-heading-m">Cool colours</h3> | ||
{{ govukRadios({ | ||
idPrefix: "cool", | ||
name: "colour", | ||
items: [ | ||
{ | ||
value: "blue", | ||
text: "Blue", | ||
conditional: { | ||
html: '<p class="govuk-body">Nice choice, I like blue too.</p>' | ||
} | ||
}, | ||
{ | ||
value: "green", | ||
text: "Green", | ||
conditional: { | ||
html: '<p class="govuk-body">Boo, you monster...</p>' | ||
} | ||
} | ||
] | ||
}) }} | ||
|
||
<h3 class="govuk-heading-m">Do you like colours in general?</h3> | ||
{{ govukRadios({ | ||
idPrefix: "colours-in-general", | ||
name: "colours-in-general", | ||
items: [ | ||
{ | ||
value: "yes", | ||
text: "Yes", | ||
conditional: { | ||
html: '<p class="govuk-body">Fair enough.</p>' | ||
} | ||
}, | ||
{ | ||
value: "no", | ||
text: "No", | ||
conditional: { | ||
html: '<p class="govuk-body">No judgment.</p>' | ||
} | ||
} | ||
] | ||
}) }} | ||
</fieldset> | ||
{{ govukButton({ | ||
text: "Submit" | ||
}) }} | ||
</form> | ||
</div> | ||
<div class="govuk-grid-column-one-half"> | ||
<form method="get" novalidate> | ||
<fieldset class="govuk-fieldset"> | ||
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l"> | ||
<h2 class="govuk-fieldset__heading"> | ||
What is your least favourite colour? | ||
</h2> | ||
</legend> | ||
<h3 class="govuk-heading-m">Warm colours</h3> | ||
{{ govukRadios({ | ||
idPrefix: "least-warm", | ||
name: "colour", | ||
items: [ | ||
{ | ||
value: "red", | ||
text: "Red", | ||
conditional: { | ||
html: '<p class="govuk-body">Nice choice, I like red too.</p>' | ||
} | ||
}, | ||
{ | ||
value: "orange", | ||
text: "Orange", | ||
conditional: { | ||
html: '<p class="govuk-body">Nice choice, I like orange too.</p>' | ||
} | ||
} | ||
] | ||
}) }} | ||
|
||
<h3 class="govuk-heading-m">Cool colours</h3> | ||
{{ govukRadios({ | ||
idPrefix: "least-cool", | ||
name: "colour", | ||
items: [ | ||
{ | ||
value: "blue", | ||
text: "Blue", | ||
conditional: { | ||
html: '<p class="govuk-body">Nice choice, I like blue too.</p>' | ||
} | ||
}, | ||
{ | ||
value: "green", | ||
text: "Green", | ||
conditional: { | ||
html: '<p class="govuk-body">Boo, you monster...</p>' | ||
} | ||
} | ||
] | ||
}) }} | ||
</fieldset> | ||
{{ govukButton({ | ||
text: "Submit" | ||
}) }} | ||
</form> | ||
|
||
<h3 class="govuk-heading-m">A question that is not in a form</h3> | ||
{{ govukRadios({ | ||
idPrefix: "question-not-in-form", | ||
name: "question-not-in-form", | ||
items: [ | ||
{ | ||
value: "yes", | ||
text: "Yes", | ||
conditional: { | ||
html: '<p class="govuk-body">Fair enough.</p>' | ||
} | ||
}, | ||
{ | ||
value: "no", | ||
text: "No", | ||
conditional: { | ||
html: '<p class="govuk-body">No judgment.</p>' | ||
} | ||
} | ||
] | ||
}) }} | ||
</div> | ||
</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