mirror of
https://github.com/IT4Change/ohmyform-ui.git
synced 2025-12-13 09:45:50 +00:00
fix yes / no field
This commit is contained in:
parent
f42e8b9e7c
commit
dfc1fd6cc0
@ -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
|
||||
|
||||
@ -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>
|
||||
)
|
||||
|
||||
@ -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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user