Basic styling making form error messages look a little bit better.
authorMagnus Hagander <magnus@hagander.net>
Tue, 30 Mar 2010 16:26:30 +0000 (18:26 +0200)
committerMagnus Hagander <magnus@hagander.net>
Tue, 30 Mar 2010 16:26:30 +0000 (18:26 +0200)
media/css/layout.css
templates/base/form.html

index eec06bd6943322d0661c96f93e179615a847fab7..80baf12e10da396a037ec5b6d2c8bf6502fe0bc1 100644 (file)
@@ -644,6 +644,10 @@ TABLE.pgGenericFormTable TR TD INPUT {
    width: 100%;
 }
 
+TABLE.pgGenericFormTable TR TD SELECT {
+   width: 100%;
+}
+
 TABLE.pgGenericFormTable TR TD TEXTAREA {
    width: 100%;
 }
@@ -652,6 +656,21 @@ TABLE.pgGenericFormTable TR TD DIV.markdownpreview {
    width: 100%;
 }
 
+TABLE.pgGenericFormTable TR.error {
+   background-color: red;
+   color: white;
+}
+
+TABLE.pgGenericFormTable TR.errorinfo {
+   background-color: #FFFFCC;
+}
+
+TABLE.pgGenericFormTable TR.errorheader TD {
+   background-color: #FFFFCC;
+   border: 1px solid red;
+   padding: 2px 2px 2px 2px;
+}
+
 /* Misc Classes */
 
 .pgClearBoth {
index f60641e85812b08dff89ff39b0b514eb9fe143f3..a4332b1c1d8674ee944dc8a7f91e8fd75c7bc46b 100644 (file)
@@ -9,7 +9,22 @@
 {%endif%}
 
 <table class="pgGenericFormTable">
-{{form.as_table}}
+{%if form.errors%}
+ <tr class="errorheader">
+  <td colspan="2">Please correct the errors below, and re-submit the form.</td>
+ </tr>
+{%endif%}
+{%for field in form%}
+ {%if field.errors %}
+ <tr class="error">
+  <td colspan="2">{{field.errors.as_ul}}</td>
+ </tr>
+ {%endif%}
+ <tr {%if field.errors%}class="errorinfo"{%endif%}>
+  <th>{{field.label_tag}}</th>
+  <td>{{field}}</td>
+ </tr>
+{%endfor%}
 </table>
 <input type="submit" value="{{savebutton|default:"Save"}}">
 </form>