Skip to content

Commit

Permalink
feat(custom attributes): add "No value" option to optionset attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 committed Oct 25, 2023
1 parent 92fb57a commit de8cf8c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pages/dataElements/form/CustomAttributes.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import i18n from '@dhis2/d2-i18n'
import { InputFieldFF, SingleSelectFieldFF, TextAreaFieldFF } from '@dhis2/ui'
import * as React from 'react'
import { Field as FieldRFF } from 'react-final-form'
Expand All @@ -15,13 +16,18 @@ function CustomAttribute({ attribute, index }: CustomAttributeProps) {
const name = `attributeValues[${index}].value`

if (attribute.optionSet?.options) {
const options = attribute.optionSet?.options.map(
const attributeOptions = attribute.optionSet?.options.map(
({ code, displayName }) => ({
value: code,
label: displayName,
})
)

const options = [
{ value: '', label: i18n.t('<No value>') },
...(attributeOptions || []),
]

return (
<StandardFormSection key={attribute.id}>
<FieldRFF
Expand Down

0 comments on commit de8cf8c

Please sign in to comment.