Skip to content

Commit

Permalink
fix(form): add no value to custom attribute optionset
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo committed Oct 24, 2023
1 parent c1ec75f commit 9b26d47
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/pages/dataElements/form/CustomAttributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ type CustomAttributeProps = {
index: number
}

type DisplayOptions = Array<{
value: string | undefined
label: string
}>

function CustomAttribute({ attribute, index }: CustomAttributeProps) {
const name = `attributeValues[${index}].value`

if (attribute.optionSet?.options) {
const options = attribute.optionSet?.options.map(
let options: DisplayOptions = [
{ value: undefined, label: i18n.t('<No value>') },
]
const mappedOptions = attribute.optionSet.options.map(
({ code, displayName }) => ({
value: code,
label: displayName,
})
)
options = options.concat(mappedOptions)

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

0 comments on commit 9b26d47

Please sign in to comment.