Skip to content
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

Support array of strings in radios and checkboxes #4032

Open
joelanman opened this issue Aug 1, 2023 · 3 comments
Open

Support array of strings in radios and checkboxes #4032

joelanman opened this issue Aug 1, 2023 · 3 comments
Labels

Comments

@joelanman
Copy link
Contributor

joelanman commented Aug 1, 2023

Related component

Radios and checkboxes

Context

You don't always want different name from text, for example when prototyping. An array of strings is a lot simpler than an array of objects. For example:

items: ["England", "Northern Ireland", "Scotland", "Wales"]

compared to the current approach:

items: [
  {"name": "England", "text": "England"},
  {"name": "Northern Ireland", "text": "Northern Ireland"},
  {"name": "Scotland", "text": "Scotland"},
  {"name": "Wales", "text": "Wales"}
]

(In this suggestion only text is supported - if you want other options like html or hint you'd have to use the object approach)

@joelanman joelanman added feature request User requests a new feature awaiting triage Needs triaging by team labels Aug 1, 2023
@querkmachine
Copy link
Member

I think we may have already resolved this recently! #3773

@joelanman
Copy link
Contributor Author

Hi that link is for the select element? Was the same thing done for radios and checkboxes?

@querkmachine
Copy link
Member

Ah whoops, no it wasn't, sorry!

Making the same change for checkboxes and radios may be a bit more involved as they each have several more parameters that can slot into the object within items, but it's not impossible.

I worry a little about maintainability from the user's perspective—if they've used the string array syntax and now decided they want to add hint text to an option, for example, they would need to completely reformat how they're providing data to allow that, which they wouldn't need to do if they were using the object syntax.

Maybe even if we allow an array of strings, it'd be better to have it as a bit of a 'hidden' feature rather than something we encourage the use of.

@querkmachine querkmachine added checkboxes radios nunjucks and removed awaiting triage Needs triaging by team labels Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants