Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#13426 closed (invalid)

Multiple choice SELECT-element prints newline for each OPTION.

Reported by: Mika Marttila Owned by: nobody
Component: Forms Version: master
Severity: Keywords: multiple
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Found this from Django Admin. Each OPTION in multiple choice SELECT-box prints newline to template. These lines are located between opening SELECT-tag and OPTION-tags.

Someone else must've noticed this before but I didn't find a ticket. I'm running Django from SVN with revision 11092.

Change History (8)

comment:1 Changed 7 years ago by Alex Gaynor

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

So? Whitespace beyond single spaces has no significance in HTML.

comment:2 Changed 7 years ago by Mika Marttila

.. and Firebug ignores such newlines anyway.

I noticed it when I copied source code for a feature mockup. I had a SELECT box with 1608 options. That makes 3216 extra newlines in template. So why? Because it's just wrong!

comment:3 Changed 7 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed
class MyForm(forms.Form):
    selection = forms.MultipleChoiceField(choices=(
        ('2','Something Else'),
        ('3','Third Option'),

print Template("""
{{ form }}


<tr><th><label for="id_selection">Selection:</label></th><td><select multiple="multiple" name="selection" id="id_selection">
<option value="1">Something</option>
<option value="2">Something Else</option>
<option value="32">Third Option</option>

I originally thought there might have been extra newlines slipping in somewhere leading to blank lines in rendered output; but if what you're complaining about is that there is a newline between options, then I'm going to call this wontfix. Having options on separate lines makes the HTML much easier to read (in case it needs to be human readable), doesn't bloat the page size by too much, and is syntactically irrelevant from the point of view of the spec.

comment:4 Changed 7 years ago by Mika Marttila

Resolution: wontfix
Status: closedreopened

Sorry, I should've mentioned that my Django Admin is working on tableless setup.

Newlines appear between opening SELECT-tag and all OPTION-tags. OPTION-tags are not on separate lines. Like this:

select multiple="multiple" name="selection" id="id_selection">

<option value="1">Something</option><option value="2">Something Else</option><option value="32">Third Option</option>

comment:5 Changed 7 years ago by Russell Keith-Magee

Resolution: invalid
Status: reopenedclosed

Ok -seriously, I have absolutely no idea what you're talking about. "Admin is working on tableless setup"? What does this mean?

I still can't reproduce this problem. If I put a model with a choices field into the admin, I get the same rendered output for the select as I gave previously. Which is hardly surprising, given that the admin uses the same basic widget set.

If you want us to take a bug report seriously, you need to give *specific* instructions on how to reproduce your problem.

comment:6 Changed 7 years ago by Mika Marttila

Sorry if my terms are unclear.

Tableless setup means that it's not using TABLEs for layout. I'm so used to it that I can't remember if it's done by some plugin or other 3rd party thing. If so, then this bug is invalid.

I'm happy with the resolution: whatever.

comment:7 Changed 7 years ago by Russell Keith-Magee

I know what tableless layout is. What I don't know is how you're getting a tableless layout in Django's admin, because that isn't an option out of the box. As always, the details -- like the fact that you're using a third party plugin -- matter a lot.

comment:8 Changed 6 years ago by Gabriel Hurley

@aom, the best thing here would be if you could package up a small test case and attach it to this ticket so that we can see what you're doing and confirm whether or not the bug exists.

Note: See TracTickets for help on using tickets.
Back to Top