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

[bug] checkboxmultipleselect is a radio #126

Open
rosscdh opened this issue Sep 8, 2022 · 2 comments · May be fixed by #127
Open

[bug] checkboxmultipleselect is a radio #126

rosscdh opened this issue Sep 8, 2022 · 2 comments · May be fixed by #127

Comments

@rosscdh
Copy link

rosscdh commented Sep 8, 2022

as per https://github.com/django/django/blob/main/django/forms/widgets.py#L839

unfortunately the widget inherits from radioselect which means that isinstance will return true an show a radio select due to the order in https://github.com/django-crispy-forms/crispy-tailwind/blob/main/crispy_tailwind/templates/tailwind/field.html#L20

as is demonstrated here

(Pdb) isinstance(form.fields.get('infrastructure').widget, forms.CheckboxSelectMultiple)
True
(Pdb) isinstance(form.fields.get('infrastructure').widget, forms.RadioSelect)
True

a working fix would be to test for the class name rather?

 form.fields.get('infrastructure').widget.__class__.__name__
'CheckboxSelectMultiple'
@rosscdh rosscdh linked a pull request Sep 8, 2022 that will close this issue
@dpjanes
Copy link

dpjanes commented Nov 14, 2023

Seconded on this one:

This is how django-crispy-forms handles it:

https://github.com/django-crispy-forms/django-crispy-forms/blob/main/crispy_forms/templatetags/crispy_forms_field.py

    return isinstance(field.field.widget, forms.RadioSelect) and not isinstance(
        field.field.widget, forms.CheckboxSelectMultiple
    )

@GitRon
Copy link
Contributor

GitRon commented Jan 5, 2024

Hi @rosscdh!

Nice to meet you here! 😄

What do you say about @dpjanes suggestion how crispy forms core handles this?

Best
Ronny

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

Successfully merging a pull request may close this issue.

3 participants