From c3fbaf336719cad4468ace1974c7289bb2705f23 Mon Sep 17 00:00:00 2001 From: Michael Schramm Date: Tue, 2 Jun 2020 08:14:38 +0200 Subject: [PATCH] fix #10 required change of default value --- components/form/types/date.type.tsx | 2 +- components/form/types/email.type.tsx | 2 +- components/form/types/link.type.tsx | 2 +- components/form/types/number.type.tsx | 2 +- components/form/types/rating.type.tsx | 3 ++- components/form/types/text.type.tsx | 2 +- components/form/types/textarea.type.tsx | 2 +- components/form/types/yes_no.type.tsx | 1 + 8 files changed, 9 insertions(+), 7 deletions(-) diff --git a/components/form/types/date.type.tsx b/components/form/types/date.type.tsx index b4e22c0..21207ec 100644 --- a/components/form/types/date.type.tsx +++ b/components/form/types/date.type.tsx @@ -17,10 +17,10 @@ export const DateType: React.FC = ({ field, design}) => { ]} getValueFromEvent={e => e.format('YYYY-MM-DD')} getValueProps={e => ({value: e ? moment(e) : undefined})} + initialValue={field.value ? moment(field.value) : undefined} > diff --git a/components/form/types/email.type.tsx b/components/form/types/email.type.tsx index 613b32a..e0a5b92 100644 --- a/components/form/types/email.type.tsx +++ b/components/form/types/email.type.tsx @@ -12,12 +12,12 @@ export const EmailType: React.FC = ({field, design}) => { { required: field.required, message: 'Please provide Information' }, { type: 'email', message: 'Must be a valid email' } ]} + initialValue={field.value} > diff --git a/components/form/types/link.type.tsx b/components/form/types/link.type.tsx index b8c11f0..af2d268 100644 --- a/components/form/types/link.type.tsx +++ b/components/form/types/link.type.tsx @@ -12,12 +12,12 @@ export const LinkType: React.FC = ({field, design}) => { { required: field.required, message: 'Please provide Information' }, { type: 'url', message: 'Must be a valid URL' } ]} + initialValue={field.value} > diff --git a/components/form/types/number.type.tsx b/components/form/types/number.type.tsx index d55f938..49a1424 100644 --- a/components/form/types/number.type.tsx +++ b/components/form/types/number.type.tsx @@ -12,11 +12,11 @@ export const NumberType: React.FC = ({field, design}) => { { type: 'number', message: 'Must be a valid URL' }, { required: field.required, message: 'Please provide Information' }, ]} + initialValue={parseFloat(field.value)} > diff --git a/components/form/types/rating.type.tsx b/components/form/types/rating.type.tsx index 8b41f56..52f76be 100644 --- a/components/form/types/rating.type.tsx +++ b/components/form/types/rating.type.tsx @@ -12,8 +12,9 @@ export const RatingType: React.FC = ({field}) => { rules={[ { required: field.required, message: 'Please provide Information' }, ]} + initialValue={parseFloat(field.value)} > - + ) diff --git a/components/form/types/text.type.tsx b/components/form/types/text.type.tsx index 458e7bb..53e8d78 100644 --- a/components/form/types/text.type.tsx +++ b/components/form/types/text.type.tsx @@ -15,12 +15,12 @@ export const TextType: React.FC = ({field, design}) => { rules={[ { required: field.required, message: 'Please provide Information' } ]} + initialValue={field.value} > diff --git a/components/form/types/textarea.type.tsx b/components/form/types/textarea.type.tsx index 267c430..c9848ff 100644 --- a/components/form/types/textarea.type.tsx +++ b/components/form/types/textarea.type.tsx @@ -11,12 +11,12 @@ export const TextareaType: React.FC = ({field, design}) => { rules={[ { required: field.required, message: 'Please provide Information' }, ]} + initialValue={field.value} > diff --git a/components/form/types/yes_no.type.tsx b/components/form/types/yes_no.type.tsx index 07b73c7..9510da2 100644 --- a/components/form/types/yes_no.type.tsx +++ b/components/form/types/yes_no.type.tsx @@ -10,6 +10,7 @@ export const YesNoType: React.FC = ({field}) => { rules={[ { required: field.required, message: 'Please provide Information' }, ]} + initialValue={field.value} >