I am working on a somewhat larger html5 form in a Gatsby site and was wondering if there is a better way to name checkboxes/radio buttons. According to the docs and what I read here each input has to have a unique name which works fine for text-fields and even dropdowns but for checkboxes and radio buttons this gets messy quite quickly.
Thank you! Works like a charm.
I got tripped up by some gatsby-netlify-forms-problems I had and thought the name not being unique was the reason. Maybe you could also add this to the example in the docs just in case somebody else has this question.
This may be a good recommendation for forms to work fine with the Netlify parser, but it propagates bad markup: some screen readers won’t be able to announce input fields like that. is the correct way to go, and if Netlify is not able to parse this correctly, I suggest it learns to do so
I guess it currently doesn’t parse correctly because at least in my case I encounter problems.
Has there been any update on this feature? Wrapping a checkbox/radio isn’t always possible or desired. Bootstrap for example doesn’t wrap them, and the accessibility factor is super important. Wrapping checkboxes/radios in a fieldset with a legend should be more than enough to use the legend as the text instead of the first label’s content.
I find the checkbox handling a bit bizarre (haven’t tested radio buttons but I’m assuming it’s the same) They’re not documented at all and the closest thing we have is “we recommend something like what Dennis posted”
To be clear, the issue isn’t that the checkbox data is not making it through, just the resulting data formatting is cryptic and passing it to someone else requires a small manual and bunch of excuses on my part.
AFAIK using the same names for all checkbox inputs (in the same group) and vary the value is the standard way to do it. But the email will use the title from the first checkbox as the title for the list of checkboxes. This leads to confusion, because it might seem like the first option was checked.
Here is my workaround solution for anyone else feeling frustrated by this.
Option #1. handle your forms using edge functions
Option #2. Add a hidden input as the first option. This will also change the label, as it will now ignore the label and use the name instead. To solve for that, use the desired label as the name in a kebab-case.