mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix required fields with default values (#3512)
This commit is contained in:
parent
ecfbfbf56b
commit
7e5f28b3cc
@ -43,17 +43,17 @@ class StepFlowForm extends LitElement {
|
|||||||
|
|
||||||
protected render(): TemplateResult | void {
|
protected render(): TemplateResult | void {
|
||||||
const step = this.step;
|
const step = this.step;
|
||||||
|
const stepData = this._stepDataProcessed;
|
||||||
|
|
||||||
const allRequiredInfoFilledIn =
|
const allRequiredInfoFilledIn =
|
||||||
this._stepData === undefined
|
stepData === undefined
|
||||||
? // If no data filled in, just check that any field is required
|
? // If no data filled in, just check that any field is required
|
||||||
step.data_schema.find((field) => !field.optional) === undefined
|
step.data_schema.find((field) => !field.optional) === undefined
|
||||||
: // If data is filled in, make sure all required fields are
|
: // If data is filled in, make sure all required fields are
|
||||||
this._stepData &&
|
stepData &&
|
||||||
step.data_schema.every(
|
step.data_schema.every(
|
||||||
(field) =>
|
(field) =>
|
||||||
field.optional ||
|
field.optional || !["", undefined].includes(stepData![field.name])
|
||||||
!["", undefined].includes(this._stepData![field.name])
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
@ -68,7 +68,7 @@ class StepFlowForm extends LitElement {
|
|||||||
: ""}
|
: ""}
|
||||||
${this.flowConfig.renderShowFormStepDescription(this.hass, this.step)}
|
${this.flowConfig.renderShowFormStepDescription(this.hass, this.step)}
|
||||||
<ha-form
|
<ha-form
|
||||||
.data=${this._stepDataProcessed}
|
.data=${stepData}
|
||||||
@data-changed=${this._stepDataChanged}
|
@data-changed=${this._stepDataChanged}
|
||||||
.schema=${step.data_schema}
|
.schema=${step.data_schema}
|
||||||
.error=${step.errors}
|
.error=${step.errors}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user