From dfc1fd6cc0354a1c30db93e39b277212230f661f Mon Sep 17 00:00:00 2001 From: Michael Schramm Date: Wed, 10 Jun 2020 17:37:20 +0200 Subject: [PATCH] fix yes / no field --- CHANGELOG.md | 3 +++ components/form/admin/types/yes_no.type.tsx | 8 ++++++-- components/form/types/yes_no.type.tsx | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c513952..dce4379 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed ### Fixed + +- yes / no field fixed on admin and user view + ### Security ## [0.9.4] - 2020-06-09 diff --git a/components/form/admin/types/yes_no.type.tsx b/components/form/admin/types/yes_no.type.tsx index e5cddcc..e906331 100644 --- a/components/form/admin/types/yes_no.type.tsx +++ b/components/form/admin/types/yes_no.type.tsx @@ -1,4 +1,5 @@ -import { Form, Input } from 'antd' +import {Form, Input, Switch} from 'antd' +import moment, {Moment} from 'moment' import React from 'react' import { useTranslation } from 'react-i18next' import { AdminFieldTypeProps } from './type.props' @@ -13,8 +14,11 @@ export const YesNoType: React.FC = (props) => { label={t('type:yes_no:default')} name={[props.field.name as string, 'value']} labelCol={{ span: 6 }} + valuePropName={'checked'} + getValueFromEvent={(checked: boolean) => (checked ? '1' : '')} + getValueProps={(e: string) => ({ checked: !!e })} > - + ) diff --git a/components/form/types/yes_no.type.tsx b/components/form/types/yes_no.type.tsx index 8cdb037..9f9a41e 100644 --- a/components/form/types/yes_no.type.tsx +++ b/components/form/types/yes_no.type.tsx @@ -8,7 +8,10 @@ export const YesNoType: React.FC = ({ field }) => { (checked ? '1' : '')} + getValueProps={(e: string) => ({ checked: !!e })} >