Opened 6 years ago

Closed 5 years ago

Last modified 4 years ago

#11791 closed (fixed)

Incorrect HTML Code rendered in list_editable enabled changelists

Reported by: panni@… Owned by: kmtracey
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 mlavin 6 years ago.
Patch with tests for modified 'result_list' inclusion tag

Download all attachments as: .zip

Change History (9)

comment:1 Changed 6 years ago by romainh

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

comment:2 Changed 6 years ago by mlavin

  • Owner changed from nobody to mlavin
  • Status changed from new to assigned

comment:3 Changed 6 years ago by mlavin

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 6 years ago by mlavin

Patch with tests for modified 'result_list' inclusion tag

comment:4 Changed 6 years ago by mlavin

  • Owner changed from mlavin to kmtracey
  • Status changed from assigned to new

comment:5 Changed 6 years ago by russellm

  • Component changed from Contrib apps to django.contrib.admin
  • Has patch set
  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Accepted

comment:6 Changed 5 years ago by kmtracey

  • Resolution set to fixed
  • Status changed from new to closed

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

(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 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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