Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#13426 closed (invalid)

Multiple choice SELECT-element prints newline for each OPTION.

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

Description

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 by Alex Gaynor, 14 years ago

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

comment:2 by Mika Marttila, 14 years ago

.. 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 by Russell Keith-Magee, 14 years ago

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

print Template("""
{{ form }}
""").render(Context({'form':MyForm()}))

prints

<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>
</select></td></tr>

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 by Mika Marttila, 14 years ago

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>
</select>

comment:5 by Russell Keith-Magee, 14 years ago

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 by Mika Marttila, 14 years ago

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 by Russell Keith-Magee, 14 years ago

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 by Gabriel Hurley, 14 years ago

@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