if select has multiple, make init value an array (#17868)

if multiple, make it an array
This commit is contained in:
Bram Kragten 2023-09-08 19:46:40 +02:00 committed by GitHub
parent 0276430ab5
commit eae4ca1271
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,8 +61,10 @@ export const computeInitialHaFormData = (
data[field.name] = selector.number?.min ?? 0;
} else if ("select" in selector) {
if (selector.select?.options.length) {
const val = selector.select.options[0];
data[field.name] = typeof val === "string" ? val : val.value;
const firstOption = selector.select.options[0];
const val =
typeof firstOption === "string" ? firstOption : firstOption.value;
data[field.name] = selector.select.multiple ? [val] : val;
}
} else if ("duration" in selector) {
data[field.name] = {