From eae4ca127105ea95a7019ab158db9e5b868daefc Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 8 Sep 2023 19:46:40 +0200 Subject: [PATCH] if select has multiple, make init value an array (#17868) if multiple, make it an array --- src/components/ha-form/compute-initial-ha-form-data.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/ha-form/compute-initial-ha-form-data.ts b/src/components/ha-form/compute-initial-ha-form-data.ts index d3c7e2b84708..98b67274fc56 100644 --- a/src/components/ha-form/compute-initial-ha-form-data.ts +++ b/src/components/ha-form/compute-initial-ha-form-data.ts @@ -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] = {