From 42819cf2fcb6f4b8b705a556773b7a60f799d56b Mon Sep 17 00:00:00 2001 From: "Silvio J. Gutierrez" Date: Sat, 7 Jul 2018 19:07:18 -0400 Subject: [PATCH] Field errors. --- components/Form.tsx | 20 ++++++++++++++++---- server/db.sqlite3 | Bin 143360 -> 147456 bytes server/server/views.py | 8 +++++++- 3 files changed, 23 insertions(+), 5 deletions(-) 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 d762083358e12c3618d6337b6e12218d0adab1fe..10cbdc5f809f15abc02584119d90f5c6b7218497 100644 GIT binary patch delta 1366 zcmb`HU5Fc16vyXeX7aIdA06&J zGxyv-_uO;t{Y`V#-fTLKdHNF+MFmLrlMbX$AKy9-iLu(2AZgLq{jo%Jd?L|Kcz>k%)A%{+*upYi#>?#yc@kZ2d$y3S(b+zUf85jZD9Or74 zgWdFbj^wjBwc#FMAP6?ol}R_$oK~9~ZhM~l79uPSV3iHaN`__phNXRm zwRjoY0UqPi?l!D#xZPMemby>0oT4xwT;fK#^NydaU)y&$!`318Y341)N>}-1ULt}I zsGrFN+Ue4#AA)?+b`x&6;&FJDZls?tsdqioyE^r6iy*P)nd@h>FwyaqAZFv!g1Ej|gsl+JzbnF% zdb$jL-Ccq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