#35755: Regression: Help text for hidden fields shows
--------------------------------+-----------------------------------------
Reporter: Richard Laager | Type: Bug
Status: new | Component: contrib.admin
Version: 4.2 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+-----------------------------------------
This is present in 4.2 through git main.
If a field is hidden, its help_text shows.
This regressed in commit 96a598356a9ea8c2c05b22cadc12e256a3b295fd:
https://github.com/django/django/commit/96a598356a9ea8c2c05b22cadc12e256a3b295fd
from PR 16161:
https://github.com/django/django/pull/16161
This happened because the <div class="help"> is now after, as opposed to
inside, the <div> that gets class "hidden".
There are two possible fixes:
A) Do not output the help div at all:
{{{
--- a/django/contrib/admin/templates/admin/includes/fieldset.html
+++ b/django/contrib/admin/templates/admin/includes/fieldset.html
@@ -26,7 +26,7 @@
{% endif %}
{% endif %}
</div>
- {% if field.field.help_text %}
+ {% if field.field.help_text and not
field.field.is_hidden %}
<div class="help"{% if field.field.id_for_label
%} id="{{ field.field.id_for_label }}_helptext"{% endif %}>
<div>{{ field.field.help_text|safe }}</div>
</div>
}}}
B) Set "hidden" on the help div:
{{{
--- a/django/contrib/admin/templates/admin/includes/fieldset.html
+++ b/django/contrib/admin/templates/admin/includes/fieldset.html
@@ -27,7 +27,7 @@
{% endif %}
</div>
{% if field.field.help_text %}
- <div class="help"{% if field.field.id_for_label
%} id="{{ field.field.id_for_label }}_helptext"{% endif %}>
+ <div class="help{% if field.field.is_hidden %}
hidden{% endif %}"{% if field.field.id_for_label %} id="{{
field.field.id_for_label }}_helptext"{% endif %}>
<div>{{ field.field.help_text|safe }}</div>
</div>
{% endif %}
}}}
Either fix works. I'm just not sure stylistically which one you want.
--
Ticket URL: <https://code.djangoproject.com/ticket/35755>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070191e453a21f-b0c05601-6d64-47fe-a1a4-a3a846b629cd-000000%40eu-central-1.amazonses.com.