django-bootstrap5 icon indicating copy to clipboard operation
django-bootstrap5 copied to clipboard

CheckboxSelectMultiple: attributes doesn't show in options

Open matiasgatti opened this issue 2 years ago • 0 comments

Following the Django Docs I Have this: (Docs: https://docs.djangoproject.com/en/4.0/ref/forms/fields/#iterating-relationship-choices)

class CheckboxSelectMultipleWithAttrs(CheckboxSelectMultiple): def create_option(self, name, value, label, selected, index, subindex=None, attrs=None): option = super().create_option(name, value, label, selected, index, subindex, attrs) if value: option['attrs']['data-total'] = value.instance.total return option

If a render the widget with Django i get the attrs: (...) <input type="checkbox" name="ventas" value="95" id="id_ventas_0" data-total="5220"> <input type="checkbox" name="ventas" value="94" id="id_ventas_1" data-total="6000"> (...)

BUT If I render with django-bootstrap5 I dont get the attrs. (data-total) on the checkbox.

matiasgatti avatar Mar 10 '22 16:03 matiasgatti