fix yes / no field

This commit is contained in:
Michael Schramm 2020-06-10 17:37:20 +02:00
parent f42e8b9e7c
commit dfc1fd6cc0
3 changed files with 13 additions and 3 deletions

View File

@ -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

View File

@ -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<AdminFieldTypeProps> = (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 })}
>
<Input />
<Switch />
</Form.Item>
</div>
)

View File

@ -8,7 +8,10 @@ export const YesNoType: React.FC<FieldTypeProps> = ({ field }) => {
<Form.Item
name={[field.id, 'value']}
rules={[{ required: field.required, message: 'Please provide Information' }]}
initialValue={field.value}
initialValue={!!field.value}
valuePropName={'checked'}
getValueFromEvent={(checked: boolean) => (checked ? '1' : '')}
getValueProps={(e: string) => ({ checked: !!e })}
>
<Switch />
</Form.Item>