Skip to content

Commit

Permalink
Fixed #13782 -- Added CSS for errors in textareas and multiple fields…
Browse files Browse the repository at this point in the history
… in one line. Thanks, julien.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14999 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jezdez committed Dec 21, 2010
1 parent b224b05 commit 75f1698
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions django/contrib/admin/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def label_tag(self):
attrs = classes and {'class': u' '.join(classes)} or {}
return self.field.label_tag(contents=contents, attrs=attrs)

def errors(self):
return mark_safe(self.field.errors.as_ul())

class AdminReadonlyField(object):
def __init__(self, form, field, is_first, model_admin=None):
label = label_for_field(field, form._meta.model, model_admin)
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/admin/media/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ td ul.errorlist li {
background: #ffc;
}

.errors input, .errors select {
.errors input, .errors select, .errors textarea {
border: 1px solid red;
}

Expand Down
7 changes: 4 additions & 3 deletions django/contrib/admin/templates/admin/includes/fieldset.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
<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 %}">
{{ line.errors }}
<div class="form-row{% if line.fields|length_is:'1' and line.errors %} errors{% endif %}{% for field in line %} {{ field.field.name }}{% endfor %}">
{% if line.fields|length_is:'1' %}{{ line.errors }}{% endif %}
{% for field in line %}
<div{% if not line.fields|length_is:"1" %} class="field-box"{% endif %}>
<div{% if not line.fields|length_is:'1' %} class="field-box{% if not field.is_readonly and field.errors %} errors{% endif %}"{% endif %}>
{% if not line.fields|length_is:'1' and not field.is_readonly %}{{ field.errors }}{% endif %}
{% if field.is_checkbox %}
{{ field.field }}{{ field.label_tag }}
{% else %}
Expand Down

0 comments on commit 75f1698

Please sign in to comment.