diff --git a/components/Form.tsx b/components/Form.tsx index 628c456ff..1750aa7e7 100644 --- a/components/Form.tsx +++ b/components/Form.tsx @@ -3,6 +3,8 @@ import React from 'react'; import {Widget, WidgetType} from './Widget'; interface Field { + name: string; + label: string; widget: WidgetType; } @@ -10,7 +12,7 @@ type FormError = string[]; export type FormType = { errors: { - [name: string]: FormError; + [name: string]: FormError|null; }; fields: Field[]; } @@ -23,12 +25,22 @@ interface Props { export const Form = (props: Props) => { return
- {Object.keys(props.form.errors).length > 0 && + {/*Object.keys(props.form.errors).length > 0 &&
{JSON.stringify(props.form.errors, null, 2)}
- } + */} {props.form.fields.map(field =>
- + + {props.form.errors[field.name] != null && +
    + {props.form.errors[field.name]!.map((error, index) => +
  • {error}
  • + )} +
+ }
)} diff --git a/server/db.sqlite3 b/server/db.sqlite3 index d76208335..10cbdc5f8 100644 Binary files a/server/db.sqlite3 and b/server/db.sqlite3 differ diff --git a/server/server/views.py b/server/server/views.py index f0cc65280..674a44930 100644 --- a/server/server/views.py +++ b/server/server/views.py @@ -55,7 +55,13 @@ class Meta: serialized_form = { 'errors': form.errors, - 'fields': [simplejson.loads(str(field)) for field in form], + 'fields': [ + { + **simplejson.loads(str(field)), + 'name': field.name, + 'label': field.label, + } for field in form + ], } response = JSXResponse(