#2612 closed defect (fixed)
Fix admin formatting when help_text used with multiple fields on the same line
Reported by: | Owned by: | xian | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | minor | Keywords: | nfa-someday |
Cc: | farcepest@…, andy@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
If you have a case where you have set multiple fields to appear on the same line in the admin interface, the current version produces a line break when help_text is present, due to it being in a <p> element. To fix it in a half-assed sort of way, I wrapped the entire field in a <div style="float: left">. The diff is should below:
Index: django/contrib/admin/templates/admin/field_line.html =================================================================== --- django/contrib/admin/templates/admin/field_line.html (revision 3669) +++ django/contrib/admin/templates/admin/field_line.html (working copy) @@ -2,9 +2,11 @@ <div class="{{ class_names }}" > {% for bound_field in bound_fields %}{{ bound_field.html_error_list }}{% endfor %} {% for bound_field in bound_fields %} + <div style="float: left;"> {% if bound_field.has_label_first %}{% field_label bound_field %}{% endif %} {% field_widget bound_field %} {% if not bound_field.has_label_first %}{% field_label bound_field %}{% endif %} {% if bound_field.field.help_text %}<p class="help">{{ bound_field.field.help_text }}</p>{% endif %} + </div> {% endfor %} </div>
Ultimately you want a class which does this, which means changing the admin stylesheet, so you probably don't want to use this patch exactly.
The patch does not appear to affect the default case of stacked fields, as the the field line itself is wrapped in another <div>.
Attachments (6)
Change History (27)
by , 18 years ago
Attachment: | admin-formatting.diff added |
---|
comment:1 by , 18 years ago
I can confirm this patch fixes the above problem. I would upload before / after screenshots but trac won't let me.
Probably needs some more testing to make sure this doesn't break any existing fields.
by , 17 years ago
Attachment: | help_text_patch.diff added |
---|
comment:2 by , 17 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Expanded on the idea above using the float-left css class that was already in the admin. I have tested it with a few examples, but still needs more testing. Not sure if this applies to the newforms-admin branch.
comment:3 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Triage Stage: | Accepted → Ready for checkin |
comment:4 by , 17 years ago
Keywords: | sprintsept14 added |
---|
comment:5 by , 17 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
It's not closed until it's checked in
comment:6 by , 17 years ago
Patch needs improvement: | set |
---|---|
Summary: | [patch] Fix admin formatting when help_text used with multiple fields on the same line → Fix admin formatting when help_text used with multiple fields on the same line |
Triage Stage: | Ready for checkin → Accepted |
Version: | SVN → newforms-admin |
This needs to be fixed in newforms-admin, as it will soon will be replacing the current admin.
comment:7 by , 17 years ago
Keywords: | help_text added |
---|---|
Owner: | changed from | to
Status: | reopened → new |
Assigning to myself to make sure it gets attended to in newforms-admin. We're allowing stacked inlines to take full fieldsets so we have a there will be edge cases there to work out.
comment:8 by , 17 years ago
Keywords: | nfa-someday added; sprintsept14 help_text removed |
---|
Formatting improvement for a problem that was noted in old admin, should not block newforms-admin merge.
comment:9 by , 17 years ago
milestone: | → 1.0 |
---|
comment:10 by , 16 years ago
I attached a patch that applies on the latest trunk (r8388). I am not a UI designer nor really that great with front-end work. However, this does fix the problem of the line break, but doesn't seem 100% ideal. Also if there is no help_text on the first field in a two field grouping, but help_text on the second one, then the latter's help_text is placed under the first. Ideally someone with better skills in this area is required. :)
comment:11 by , 16 years ago
Closed #7054 as a duplicate. The patch there provides a fix to the problem I described in my last comment.
comment:12 by , 16 years ago
I've tried to test this ticket, but I've not found right admin options for placing two fields in same line. I've been trying with this, but I didn't find the correct CSS class for placing into same line:
# model: class Person(models.Model): name = models.CharField(max_length=128, help_text="Please input the name") date_joined = models.DateTimeField() # admin: class PersonAdmin(admin.ModelAdmin): fieldsets = (('Avanced options', {'classes': '????????', # what CSS class? 'fields': ('person', 'date_joined')}),)
What CSS class we use? Is correct this approach to reproduce UI bug?
comment:13 by , 16 years ago
Sorry for previous comment, correct last line was:
'fields': ('name', 'date_joined')}),)
comment:14 by , 16 years ago
Version: | newforms-admin → SVN |
---|
@msaelices: don't worry about testing this. Jacob and I sat down with a designer (Nathan Borror) last week and discussed this. He's going to look at some solutions that will work. We'll use whatever he comes up with. (By the way, the feature you were looking for is fieldsets
and then tuples of fields).
comment:15 by , 16 years ago
@mtredinnick, ok. I'll wait :-P, but, I think fieldsets
is just I put in my PersonAdmin
options, isn't?
comment:16 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:17 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Reopening since we now have a patch from nathan, a real designer :P
comment:18 by , 16 years ago
With all due respect patching a global CSS class like .float-left seems unreasonable, creating an own class should also work.
Also, please fix it for rtl-languages.
by , 16 years ago
Attachment: | ticket2612-r8860.diff added |
---|
Fix that doesn't patch float-left class and is rtl compatible.
comment:20 by , 16 years ago
Cc: | added |
---|
Proper patch for the fix. Adds a form-row-item class and applies it with a div around every bound_field