fixes crash when options was empty
This commit is contained in:
parent
17e4ff1c60
commit
9b13879b27
|
@ -20,10 +20,9 @@
|
||||||
|
|
||||||
const setFieldText = (value) => {
|
const setFieldText = (value) => {
|
||||||
if (fieldSchema?.oneToMany) {
|
if (fieldSchema?.oneToMany) {
|
||||||
if (value?.length) {
|
if (value?.length && options?.length) {
|
||||||
const row = options.find(row => row._id === value)
|
const row = options.find(row => row._id === value[0])
|
||||||
if (!row) return placeholder || 'Choose an option'
|
return row.name
|
||||||
return getDisplayName(row)
|
|
||||||
} else {
|
} else {
|
||||||
return placeholder || 'Choose an option'
|
return placeholder || 'Choose an option'
|
||||||
}
|
}
|
||||||
|
@ -36,9 +35,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: console.log(placeholder)
|
$: options, fieldText = setFieldText($fieldState?.value)
|
||||||
|
|
||||||
$: fieldText = setFieldText($fieldState?.value)
|
|
||||||
$: valueLookupMap = getValueLookupMap($fieldState?.value)
|
$: valueLookupMap = getValueLookupMap($fieldState?.value)
|
||||||
$: isOptionSelected = option => valueLookupMap[option] === true
|
$: isOptionSelected = option => valueLookupMap[option] === true
|
||||||
$: linkedTableId = fieldSchema?.tableId
|
$: linkedTableId = fieldSchema?.tableId
|
||||||
|
|
Loading…
Reference in New Issue