Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#11791 closed (fixed)

Incorrect HTML Code rendered in list_editable enabled changelists

Reported by: panni@… Owned by: Karen Tracey
Component: contrib.admin Version: 1.1
Severity: Keywords: list_editable, admin_list.py, items_for_result, opera
Cc: romain_hardouin@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

items_for_result in django.contrib.admin.templatetags.admin_list.py appends the hidden field for the form-id to the output which, in the case of the multiple forms in the change form, results in an input field right after the last field which has been rendered:

Example:

<td><img src="http://127.0.0.1:8199/media/img/admin/icon-no.gif" alt="False" /></td><td><img src="http://127.0.0.1:8199/media/img/admin/icon-no.gif" alt="0" /></td><input type="hidden" name="form-1-id" value="3287" id="id_form-1-id" /></tr>

As far as I know that type of HTML element isn't allowed between the closing tags of TD and TR. This results in corrupted output when using Opera to view such a change list - it renders an empty blue line on top of the change list for every item in the change list.

A quick fix would be to let items_for_result "inject" the hidden input right after the last field itself, inside its TD, not outside.

Attachments (1)

result_list.diff (4.2 KB ) - added by Mark Lavin 15 years ago.
Patch with tests for modified 'result_list' inclusion tag

Download all attachments as: .zip

Change History (9)

comment:1 by romainh, 15 years ago

Cc: romain_hardouin@… added

comment:2 by Mark Lavin, 15 years ago

Owner: changed from nobody to Mark Lavin
Status: newassigned

comment:3 by Mark Lavin, 15 years ago

It looks like line 245 in contrib/admin/templatetags/admin_list.py is missing the cell tags wrapper:

yield mark_safe(force_unicode(form[cl.model._meta.pk.name]))

Changing this to

yield mark_safe(u'<td>%s</td>' % force_unicode(form[cl.model._meta.pk.name]))

would fix the HTML validation but I'm not sure if it will introduce any issues with how the table will render. Working out some appropriate tests for this.

by Mark Lavin, 15 years ago

Attachment: result_list.diff added

Patch with tests for modified 'result_list' inclusion tag

comment:4 by Mark Lavin, 15 years ago

Owner: changed from Mark Lavin to Karen Tracey
Status: assignednew

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

Component: Contrib appsdjango.contrib.admin
Has patch: set
milestone: 1.2
Triage Stage: UnreviewedAccepted

comment:6 by Karen Tracey, 15 years ago

Resolution: fixed
Status: newclosed

(In [12631]) Fixed #11791: Put hidden input elements in the change list inside td elements so they're valid HTML. Thanks panni and mlavin.

comment:7 by Karen Tracey, 15 years ago

(In [12632]) [1.1.X] Fixed #11791: Put hidden input elements in the change list inside td elements so they're valid HTML. Thanks panni and mlavin.

r12631 from trunk.

comment:8 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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