a11y: mark checkboxes as a group (#71098) #297

Merged
fpeters merged 1 commits from wip/71098-checkboxes-aria-group into main 2023-05-12 09:21:07 +02:00
1 changed files with 6 additions and 0 deletions

View File

@ -1681,6 +1681,12 @@ class CheckboxesWidget(Widget):
self.readonly = True
super().__init__(name, value, **kwargs)
@property
def content_extra_attributes(self):
content_extra_attributes = {'role': 'group'}
content_extra_attributes['aria-describedby'] = f'form_label_{self.get_name_for_id()}'
return content_extra_attributes
def is_selected(self, value):
return bool(self.value and value in self.value)