mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-08 18:39:40 +00:00
Process expandable initial data also for none required expandables (#24733)
* Process expandable initial data also for none required expandables * Update compute-initial-ha-form-data.ts * check required fields of sections too when submitting
This commit is contained in:
@@ -144,17 +144,24 @@ class StepFlowForm extends LitElement {
|
||||
private async _submitStep(): Promise<void> {
|
||||
const stepData = this._stepData || {};
|
||||
|
||||
const checkAllRequiredFields = (
|
||||
schema: readonly HaFormSchema[],
|
||||
data: Record<string, any>
|
||||
) =>
|
||||
schema.every(
|
||||
(field) =>
|
||||
(!field.required || !["", undefined].includes(data[field.name])) &&
|
||||
(field.type !== "expandable" ||
|
||||
(!field.required && data[field.name] === undefined) ||
|
||||
checkAllRequiredFields(field.schema, data[field.name]))
|
||||
);
|
||||
|
||||
const allRequiredInfoFilledIn =
|
||||
stepData === undefined
|
||||
? // If no data filled in, just check that any field is required
|
||||
this.step.data_schema.find((field) => field.required) === undefined
|
||||
: // If data is filled in, make sure all required fields are
|
||||
stepData &&
|
||||
this.step.data_schema.every(
|
||||
(field) =>
|
||||
!field.required ||
|
||||
!["", undefined].includes(stepData![field.name])
|
||||
);
|
||||
checkAllRequiredFields(this.step.data_schema, stepData);
|
||||
|
||||
if (!allRequiredInfoFilledIn) {
|
||||
this._errorMsg = this.hass.localize(
|
||||
|
||||
Reference in New Issue
Block a user