Opened 19 years ago

Closed 18 years ago

Last modified 17 years ago

#212 closed defect (fixed)

help_text is not displayed for ManyToManyField in the admin interface

Reported by: jkocherhans@… Owned by: Adrian Holovaty
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description


Change History (3)

comment:1 by jkocherhans@…, 19 years ago

The <p class="help_text"> tag is showing up in the source... I think the javascript for the multiple select boxes is overwriting it somehow. Looking into it more.

comment:2 by jkocherhans@…, 19 years ago

Ok, the javascript overwrites it on purpose... I don't think that's necessary. The code in django/conf/admin_media/js/SelectFilter2.js replaces the contents of the parent of the form element with id="id_fieldname" so if we wrap the form element in an extra <div>, only the contents of that div get replaced... the help paragraph stays untouched.

Here's a few possible fixes:

Wrap every form element in an extra <div>:

Index: django/views/admin/main.py
===================================================================
--- django/views/admin/main.py  (revision 569)
+++ django/views/admin/main.py  (working copy)
@@ -717,7 +717,7 @@
             if i > 0:
                 class_names.append('inline')
             t.append('<label for="%s"%s>%s:</label> ' % (label_name, class_names and ' class="%s"' % ' '.join(class_names) or '', capfirst(field.verbose_name)))
-            t.append(_get_admin_field_form_widget(field, name_prefix, rel, add, change))
+            t.append("<div>%s</div>" % _get_admin_field_form_widget(field, name_prefix, rel, add, change))
         if change and field.primary_key:
             t.append('{{ %soriginal.%s }}' % ((rel and name_prefix or ''), field.name))
         if change and use_raw_id_admin(field):

Wrap <select> fields in an extra <div>:

===================================================================
--- django/views/admin/main.py  (revision 569)
+++ django/views/admin/main.py  (working copy)
@@ -717,7 +717,11 @@
             if i > 0:
                 class_names.append('inline')
             t.append('<label for="%s"%s>%s:</label> ' % (label_name, class_names and ' class="%s"' % ' '.join(class_names) or '', capfirst(field.verbose_name)))
-            t.append(_get_admin_field_form_widget(field, name_prefix, rel, add, change))
+            widget_str = _get_admin_field_form_widget(field, name_prefix, rel, add, change)
+            if isinstance(field.rel, meta.ManyToMany):
+                t.append("<div>%s</div>" % widget_str)
+            else:
+                t.append(widget_str)
         if change and field.primary_key:
             t.append('{{ %soriginal.%s }}' % ((rel and name_prefix or ''), field.name))
         if change and use_raw_id_admin(field):

The other option I see is to use something custom instead of quickElement in django/conf/admin_media/js/SelectFilter2.js I'd rather not touch the javascript.

comment:3 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: newclosed

This was fixed a while back.

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