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 · 4 comments
Open

[bug] checkboxmultipleselect is a radio #126

rosscdh opened this issue Sep 8, 2022 · 4 comments

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'
@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

@GitRon
Copy link
Contributor

GitRon commented Dec 3, 2024

Hi @rosscdh and @dpjanes!

I had a second look at this issue. I think we get in some trouble once somebody starts inheriting from any base class, right?

I asked GPT to see if I'm missing something, and it suggested

type(my_class) is MyClass

This would cover the case Ross mentioned but once I start inheriting, this doesn't work. So #127 is not working - am I right?

Thx for your effort but I think we can close the PR #127.

Still, it's a valid issue and I'm open for suggestions.

Best from Cologne
Ronny

@rosscdh
Copy link
Author

rosscdh commented Dec 3, 2024 via email

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