a11y: add aria-describedby to radio buttons (#71076) #296
|
@ -272,13 +272,18 @@ class RadiobuttonsWidget(quixote.form.RadiobuttonsWidget):
|
|||
has_inside_labels = True
|
||||
a11y_labelledby = True
|
||||
a11y_role = 'group'
|
||||
content_extra_attributes = {'role': 'radiogroup'}
|
||||
|
||||
def __init__(self, name, value=None, **kwargs):
|
||||
self.extra_css_class = kwargs.pop('extra_css_class', None)
|
||||
self.options_with_attributes = kwargs.pop('options_with_attributes', None)
|
||||
super().__init__(name, value=value, **kwargs)
|
||||
|
||||
@property
|
||||
def content_extra_attributes(self):
|
||||
content_extra_attributes = {'role': 'radiogroup'}
|
||||
content_extra_attributes['aria-describedby'] = f'form_label_{self.get_name_for_id()}'
|
||||
return content_extra_attributes
|
||||
|
||||
def get_options(self):
|
||||
options = self.options_with_attributes or self.options
|
||||
for option in options:
|
||||
|
|
Loading…
Reference in New Issue