Opened 18 years ago

Closed 16 years ago

Last modified 13 years ago

#2612 closed defect (fixed)

Fix admin formatting when help_text used with multiple fields on the same line

Reported by: Andy Dustman <farcepest@…> 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)

admin-formatting.diff (1.7 KB ) - added by Andy Dustman <farcepest@…> 18 years ago.
Proper patch for the fix. Adds a form-row-item class and applies it with a div around every bound_field
help_text_patch.diff (887 bytes ) - added by hakejam 17 years ago.
2612-multiple-fields-on-line.1.diff (903 bytes ) - added by Brian Rosner 16 years ago.
updated to r8388
admin_inlines.diff (3.5 KB ) - added by nathan 16 years ago.
This one's better
admin_inlines.2.diff (3.5 KB ) - added by nathan 16 years ago.
Admin inline float fix
ticket2612-r8860.diff (4.2 KB ) - added by Jannis Leidel 16 years ago.
Fix that doesn't patch float-left class and is rtl compatible.

Download all attachments as: .zip

Change History (27)

by Andy Dustman <farcepest@…>, 18 years ago

Attachment: admin-formatting.diff added

Proper patch for the fix. Adds a form-row-item class and applies it with a div around every bound_field

comment:1 by Chris Beaven, 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 hakejam, 17 years ago

Attachment: help_text_patch.diff added

comment:2 by hakejam, 17 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

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 hakejam, 17 years ago

Resolution: fixed
Status: newclosed
Triage Stage: AcceptedReady for checkin

comment:4 by hakejam, 17 years ago

Keywords: sprintsept14 added

comment:5 by Simon G. <dev@…>, 17 years ago

Resolution: fixed
Status: closedreopened

It's not closed until it's checked in

comment:6 by Gary Wilson, 17 years ago

Patch needs improvement: set
Summary: [patch] Fix admin formatting when help_text used with multiple fields on the same lineFix admin formatting when help_text used with multiple fields on the same line
Triage Stage: Ready for checkinAccepted
Version: SVNnewforms-admin

This needs to be fixed in newforms-admin, as it will soon will be replacing the current admin.

comment:7 by xian, 17 years ago

Keywords: help_text added
Owner: changed from nobody to xian
Status: reopenednew

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 Karen Tracey <kmtracey@…>, 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 Jeff Anderson, 16 years ago

milestone: 1.0

by Brian Rosner, 16 years ago

updated to r8388

comment:10 by Brian Rosner, 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 Brian Rosner, 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 Manuel Saelices, 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 Manuel Saelices, 16 years ago

Sorry for previous comment, correct last line was:

'fields': ('name', 'date_joined')}),)

comment:14 by Malcolm Tredinnick, 16 years ago

Version: newforms-adminSVN

@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 Manuel Saelices, 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 Brian Rosner, 16 years ago

Resolution: fixed
Status: newclosed

(In [8824]) Fixed #2612 -- Fixed admin formatting when help_text is used with multiple fields on the same line.

by nathan, 16 years ago

Attachment: admin_inlines.diff added

This one's better

by nathan, 16 years ago

Attachment: admin_inlines.2.diff added

Admin inline float fix

comment:17 by Alex Gaynor, 16 years ago

Resolution: fixed
Status: closedreopened

Reopening since we now have a patch from nathan, a real designer :P

comment:18 by Jannis Leidel, 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 Jannis Leidel, 16 years ago

Attachment: ticket2612-r8860.diff added

Fix that doesn't patch float-left class and is rtl compatible.

comment:19 by Jacob, 16 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in [8871].

comment:20 by anonymous, 16 years ago

Cc: andy@… added

comment:21 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

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