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
Form attributes duplicated in 'controls' div tag when using RadioSelect or CheckboxSelectMultiple widgets #1345
Comments
hmmm yes. I think I'd tend to agree. But it's been like this ~forever (nearly 10 years at this point). It was introduced in 0097308#diff-8e3221922a193d1bb987407114a65f60b0e5a4212cead18a06c00048c2b4872f Some LayoutObjects have their own django-crispy-forms/crispy_forms/layout.py Line 744 in 443ebd2
I'd be tempted to drop the |
Is there any way that you know of to override the behavior from the form class? My real-world use case is a form that updates a portion of the page through HTMX as soon as the form is changed, so having those At present, the "workaround" I'm using is to just stick with the default |
I don't think so. The best I could suggest is to set I think we should look at correcting the template. Which template pack are you using? If folk want to target that [1] https://django-crispy-forms.readthedocs.io/en/latest/form_helper.html |
@glenvaughan did you find a workaround? i've lost 3 hours trying to get why my htmx did not work properly. it's due to that extra div thing. |
Wait, the problem seems to be fixed here: https://github.com/django-crispy-forms/crispy-bootstrap4/blame/main/crispy_bootstrap4/templates/bootstrap4/layout/radioselect.html#L4 but the release of that is missing apparently. |
Description:
When using either the
RadioSelect
orCheckboxSelectMultiple
widgets for aChoiceField
, any attributes that are applied to the form throughhelper.attrs
are being duplicated in the 'controls' div for that field when rendering the form with{% crispy form %}
Code:
forms.py
views.py
crispy_test.html
Generated HTML
Same thing happens when using
CheckboxSelectMultiple
as the widget. I have not personally witnessed this behavior on any other widgets.The text was updated successfully, but these errors were encountered: