Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CheckboxSelectMultiple: attributes doesn't show in options #300

Open
matiasgatti opened this issue Mar 10, 2022 · 0 comments
Open

CheckboxSelectMultiple: attributes doesn't show in options #300

matiasgatti opened this issue Mar 10, 2022 · 0 comments

Comments

@matiasgatti
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant