-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update guides to use new 'value' option instead of 'checked' filter #223
Merged
Conversation
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
Version [9.2.0](https://github.com/nhsuk/nhsuk-frontend/releases/tag/v9.2.0) of NHS Frontend includes a simpler way to set the pre-selected or pre-checked options for checkboxes and radios. This let you set `value: data.attribute` instead of having to use the `checked()` filter on each item within a checkbox or radio. The guide and examples can now be updated to use this.
app/views/how-tos/build-basic-prototype/show-users-answers.html
Outdated
Show resolved
Hide resolved
Co-authored-by: Colin Rotherham <[email protected]>
Co-authored-by: Colin Rotherham <[email protected]>
app/views/how-tos/build-basic-prototype/let-user-change-answers.html
Outdated
Show resolved
Hide resolved
Co-authored-by: Colin Rotherham <[email protected]>
colinrotherham
approved these changes
Feb 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since version 9.2.0 of NHS Frontend there’s now an easier, nicer way of setting the default selected radio option or default checked checkboxes.
Instead of using the
checked()
filter on eachitem
within radios and checkboxes, thevalue
(for radios) orvalues
(for checkbox) of the selected items can be set at the top level of the Nunjucks params.This pull request updates the guidance to use the newer, easier way of doing this.
The
checked
function/filter is also deleted from the guidance site as it’s no longer needed (but will remain in the kit itself for backwards-compatibility until at least the next major release).