-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: format factor from number to string on edit
- Loading branch information
Showing
2 changed files
with
30 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import i18n from '@dhis2/d2-i18n' | ||
import { InputFieldFF } from '@dhis2/ui' | ||
import React from 'react' | ||
import { useField } from 'react-final-form' | ||
import { useSchemaSectionHandleOrThrow } from '../../../lib' | ||
import { useValidator } from '../../../lib/models/useFieldValidators' | ||
|
||
export const FactorField = () => { | ||
const fieldName = 'factor' | ||
const schemaSection = useSchemaSectionHandleOrThrow() | ||
const validate = useValidator({ schemaSection, property: 'factor' }) | ||
|
||
const { input, meta } = useField(fieldName, { | ||
validate, | ||
type: 'number', | ||
format: (value) => value?.toString(), | ||
}) | ||
|
||
return ( | ||
<InputFieldFF | ||
input={input} | ||
meta={meta} | ||
inputWidth="400px" | ||
label={i18n.t('Factor')} | ||
required | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters