[Django] #20655: CheckboxSelectMultiple renders an empty widget when there are no choices

19 views
Skip to first unread message

Django

unread,
Jun 25, 2013, 3:05:34 PM6/25/13
to django-...@googlegroups.com
#20655: CheckboxSelectMultiple renders an empty widget when there are no choices
-------------------------------+--------------------
Reporter: caroline@… | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------
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>')

--
Ticket URL: <https://code.djangoproject.com/ticket/20655>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 25, 2013, 3:06:03 PM6/25/13
to django-...@googlegroups.com
#20655: CheckboxSelectMultiple renders an empty ul when there are no choices
-------------------------------+--------------------------------------

Reporter: caroline@… | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by caroline@…):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/20655#comment:1>

Django

unread,
Jun 25, 2013, 3:07:31 PM6/25/13
to django-...@googlegroups.com
#20655: CheckboxSelectMultiple renders an empty ul when there are no choices
-------------------------------+--------------------------------------

Reporter: caroline@… | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by caroline@…):

* That should say and "<ul></ul>" in the final HTML messes up the display
of the form.

--
Ticket URL: <https://code.djangoproject.com/ticket/20655#comment:2>

Django

unread,
Jun 26, 2013, 4:08:08 AM6/26/13
to django-...@googlegroups.com
#20655: CheckboxSelectMultiple renders an empty ul when there are no choices
-------------------------------------+-------------------------------------
Reporter: caroline@… | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: 1.5
Component: Forms | Resolution: wontfix
Severity: Normal | Triage Stage:
Keywords: | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by bmispelon):

* status: new => closed
* component: Uncategorized => Forms
* resolution: => wontfix
* cc: bmispelon@… (added)
* type: Bug => Cleanup/optimization


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/20655#comment:3>

Reply all
Reply to author
Forward
0 new messages