Fix nested checkboxes with single top-level node

Nested checkboxes with a single top-level node
will only have one item in their `items` list.
This is because the other choices are children of
that list item.

This means we need to check the `choices`
attribute, which lists all the checkboxes, to see
if they should be marked as a group (by being
wrapped in a `<fieldset>`) or not.
This commit is contained in:
Tom Byers
2020-04-28 17:20:09 +01:00
parent 3ebb58219d
commit 3f79881864

View File

@@ -588,7 +588,7 @@ class govukCheckboxesField(SelectMultipleField):
}
# add HTML to group items if more than one
if len(items) > 1:
if len(field.choices) > 1:
params.update({
"fieldset": {
"attributes": {"id": field.name},