Skip to content

Commit

Permalink
if select has multiple, make init value an array (#17868)
Browse files Browse the repository at this point in the history
if multiple, make it an array
  • Loading branch information
bramkragten authored Sep 8, 2023
1 parent 0276430 commit eae4ca1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/ha-form/compute-initial-ha-form-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand Down

0 comments on commit eae4ca1

Please sign in to comment.