1
0
Fork 0
mirror of synced 2024-09-29 16:51:33 +13:00

Merge pull request #4084 from bastiaanterhorst/multi-options-default-fix

Update MultiFieldSelect to accept a defaultValue
This commit is contained in:
Andrew Kingston 2022-01-19 08:54:39 +00:00 committed by GitHub
commit 8a6a84c376
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,6 +20,7 @@
let fieldSchema
$: flatOptions = optionsSource == null || optionsSource === "schema"
$: expandedDefaultValue = expand(defaultValue)
$: options = getOptions(
optionsSource,
fieldSchema,
@ -28,6 +29,18 @@
valueColumn,
customOptions
)
const expand = values => {
if (!values) {
return []
}
if (Array.isArray(values)) {
return values
}
return values.split(",").map(value => value.trim())
}
</script>
<Field
@ -35,7 +48,7 @@
{label}
{disabled}
{validation}
{defaultValue}
defaultValue={expandedDefaultValue}
type="array"
bind:fieldState
bind:fieldApi