Opened 7 years ago

Closed 7 years ago

Last modified 5 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: UI/UX:

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 7 years ago.
Patch with tests for modified 'result_list' inclusion tag

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by romainh

Cc: romain_hardouin@… added
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 7 years ago by Mark Lavin

Owner: changed from nobody to Mark Lavin
Status: newassigned

comment:3 Changed 7 years ago by Mark Lavin

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.

Changed 7 years ago by Mark Lavin

Attachment: result_list.diff added

Patch with tests for modified 'result_list' inclusion tag

comment:4 Changed 7 years ago by Mark Lavin

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

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

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

comment:6 Changed 7 years ago by Karen Tracey

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 Changed 7 years ago by Karen Tracey

(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 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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