From 3f79881864f7b25289d7fdfe178aa6cf19f848d1 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Tue, 28 Apr 2020 17:20:09 +0100 Subject: [PATCH] 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 `
`) or not. --- app/main/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main/forms.py b/app/main/forms.py index b57701aa3..e054d9e4d 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -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},