Opened 14 years ago

Closed 13 years ago

#12646 closed (fixed)

Flawed error display in admin when using fieldsets.

Reported by: Matthew Schinckel Owned by: nobody
Component: contrib.admin Version: 1.1
Severity: Keywords: design_ux
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When using fieldsets within the admin, and an error occurs within one field of a line, then all fields within that line are marked as error by the css. That is, every field gets a red border, when really only the fields with actual errors should have a red border.

Related, but less annoying: the error messages are piled up at the top of the fieldset line, rather than being close to the field with the error.

I overcame both issues using a custom template for fieldset, and some extra css:

  • put an extra class on field.box when there are no errors for this field, and an entry in the admin-extra.css setting the border-color back.
  • remove the line.errors tag, and replace by appropriate field.field.errors tags within the for loop for fields within the line.

Change History (4)

comment:1 by Matthew Schinckel, 14 years ago

My replacement for the admin/includes/fieldset.html template, if it is useful:

<fieldset class="module aligned {{ fieldset.classes }}">
    {% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}
    {% if fieldset.description %}
        <div class="description">{{ fieldset.description|safe }}</div>
    {% endif %}
    {% for line in fieldset %}
        <div class="form-row{% if line.errors %} errors{% endif %} {% for field in line %}{{ field.field.name }} {% endfor %} ">
            {% for field in line %}
                <div{% if not line.fields|length_is:"1" %} class="field-box {% if not field.field.errors %}no-errors{% endif %}"{% endif %}>
                    {% if field.is_checkbox %}
                        {{ field.field }}{{ field.label_tag }}
                    {% else %}
                        {{ field.label_tag }}
                        {% if field.is_readonly %}
                            <p>{{ field.contents }}</p>
                        {% else %}
                            {{ field.field }}
                        {% endif %}
                    {% endif %}
                    {% if field.field.errors %}
                        {{ field.field.errors }}
                    {% endif %}
                    {% if field.field.field.help_text %}
                        <p class="help">{{ field.field.field.help_text|safe }}</p>
                    {% endif %}
                </div>
            {% endfor %}
        </div>
    {% endfor %}
</fieldset>

comment:2 by Matthew Schinckel, 14 years ago

Note: I haven't submitted a patch against django, as i am overriding the template in my project(s).

comment:3 by Russell Keith-Magee, 14 years ago

Component: Uncategorizeddjango.contrib.admin
Keywords: design_ux added
Triage Stage: UnreviewedAccepted

comment:4 by Julien Phalip, 13 years ago

Resolution: fixed
Status: newclosed

I'm pretty sure this was fixed in [14999].

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