alphagov / govuk-prototype-kit-docs

Site for the GOV.UK Prototype Kit
https://prototype-kit.service.gov.uk/docs
MIT License
3 stars 2 forks source link

Use the new `value` feature in Frontend #115

Closed joelanman closed 1 year ago

joelanman commented 2 years ago

Context

GOV.UK Frontend has a new feature to set values in components. We should update the kit/docs (the checked function is covered in the tutorial)

Alternatives

Currently the kit has a function called checked that achieves the same thing. Maybe we can retire it in favour of values

Done when

36degrees commented 2 years ago

Related proof of concept I put together previously – https://github.com/alphagov/govuk-prototype-kit/pull/1316

I think all form components except date input could be extended in the same way to pre-populate values from the data object.

joelanman commented 1 year ago

We still need checked if people write html instead of using nunjucks macros - possibly we can replace with raw nunjucks like

{{ 'checked' if data['fruit'] == 'apples' ] }}

not sure if you can write something similar for checkboxes (arrays)