Opened 11 years ago
Closed 11 years ago
#20655 closed Cleanup/optimization (wontfix)
CheckboxSelectMultiple renders an empty ul when there are no choices
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Forms | Version: | 1.5 |
Severity: | Normal | Keywords: | |
Cc: | bmispelon@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
This is particularly pertinent in the case of ModelChoiceField, where it may be desired that there are not yet any choices, and a '<ul></ul>' in the source code messes up the rendering.
This is caused in django.forms.widgets, line 759.
I propose to delete lines 759 and 777 and on line 777:
if len(output):
output.insert(0, '<ul>')
output.append('</ul>')
Change History (3)
comment:1 by , 11 years ago
Summary: | CheckboxSelectMultiple renders an empty widget when there are no choices → CheckboxSelectMultiple renders an empty ul when there are no choices |
---|
comment:2 by , 11 years ago
- That should say and "<ul></ul>" in the final HTML messes up the display of the form.
comment:3 by , 11 years ago
Cc: | added |
---|---|
Component: | Uncategorized → Forms |
Resolution: | → wontfix |
Status: | new → closed |
Type: | Bug → Cleanup/optimization |
Hi,
An empty <ul>
is valid markup so it shouldn't mess up the displaying of a form.
This might be a CSS issue instead.
I'm -1 on the idea of changing the behavior of CheckboxSelectMultiple
for the following reasons:
1) Backwards compatibility issues: we can't simply change this behavior since other users are probably relying on it.
2) Consistency with other widgets: a Select
widgets renders as an empty <select>
when its choices
are empty, not an empty string.
3) It shouldn't be hard to implement a custom widget if you wanted this behavior. With the refactor introduced in commit 9ac4dbd7b53d187ca54f28e247d3a120660938ca, all you'd need to do would be to write a custom renderer
for the widget.
For these reasons, I'm going to close this as wontfix
.
Don't hesitate to reopen this ticket if you disagree with me and if you have arguments that address the concerns I've raised.
There's also the django-developers mailing list where you can start a discussion about this issue: http://groups.google.com/group/django-developers.
Thanks.