mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16:36 +00:00
Allow passing the current value to config flow input fields (#5603)
* Allow passing the current value to config flow input fields * Fix lint errors * Apply suggestions from code review Co-Authored-By: Bram Kragten <mail@bramkragten.nl> * Rename current_value to suggested_value to open up more use cases * Update ha-form-integer.ts Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
dfd9bf3c64
commit
1687d90d02
@ -77,7 +77,12 @@ export class HaFormInteger extends LitElement implements HaFormElement {
|
||||
}
|
||||
|
||||
private get _value() {
|
||||
return this.data || this.schema.default || 0;
|
||||
return (
|
||||
this.data ||
|
||||
this.schema.description?.suggested_value ||
|
||||
this.schema.default ||
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
private _handleCheckboxChange(ev: Event) {
|
||||
|
@ -30,7 +30,7 @@ export interface HaFormBaseSchema {
|
||||
default?: HaFormData;
|
||||
required?: boolean;
|
||||
optional?: boolean;
|
||||
description?: { suffix?: string };
|
||||
description?: { suffix?: string; suggested_value?: HaFormData };
|
||||
}
|
||||
|
||||
export interface HaFormIntegerSchema extends HaFormBaseSchema {
|
||||
|
@ -122,7 +122,9 @@ class StepFlowForm extends LitElement {
|
||||
|
||||
const data = {};
|
||||
this.step.data_schema.forEach((field) => {
|
||||
if ("default" in field) {
|
||||
if (field.description?.suggested_value) {
|
||||
data[field.name] = field.description.suggested_value;
|
||||
} else if ("default" in field) {
|
||||
data[field.name] = field.default;
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user