Skip to content

Commit

Permalink
add inital data for language selector (#20620)
Browse files Browse the repository at this point in the history
* add inital data for language selector

* Update compute-initial-ha-form-data.ts
  • Loading branch information
bramkragten authored Apr 25, 2024
1 parent 22b927d commit 20a3a00
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/ha-form/compute-initial-ha-form-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export const computeInitialHaFormData = (
if (selector.country?.countries?.length) {
data[field.name] = selector.country.countries[0];
}
} else if ("language" in selector) {
if (selector.language?.languages?.length) {
data[field.name] = selector.language.languages[0];
}
} else if ("duration" in selector) {
data[field.name] = {
hours: 0,
Expand All @@ -93,7 +97,9 @@ export const computeInitialHaFormData = (
) {
data[field.name] = {};
} else {
throw new Error("Selector not supported in initial form data");
throw new Error(
`Selector ${Object.keys(selector)[0]} not supported in initial form data`
);
}
}
});
Expand Down

0 comments on commit 20a3a00

Please sign in to comment.