mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
options flow time_format error shows at the field instead of at the top
This commit is contained in:
@@ -63,3 +63,4 @@ repos:
|
||||
- --show-error-codes
|
||||
- --show-error-context
|
||||
- --ignore-missing-imports
|
||||
- --explicit-package-bases
|
||||
|
||||
@@ -366,7 +366,7 @@ class WasteCollectionConfigFlow(ConfigFlow, domain=DOMAIN): # type: ignore[call
|
||||
async def async_step_sensor(self, sensor_input: dict[str, Any] | None = None):
|
||||
if not hasattr(self, "sensors"):
|
||||
self.sensors = []
|
||||
errors = {}
|
||||
errors: dict[str, str] = {}
|
||||
if sensor_input is not None:
|
||||
args, errors = self.__validate_sensor_user_input(sensor_input)
|
||||
if len(errors) == 0 or args["skip"] is True:
|
||||
@@ -476,12 +476,11 @@ class WasteCollectionOptionsFlow(OptionsFlow):
|
||||
time_pattern = re.compile(r"^([01]\d|2[0-3]):([0-5]\d)$")
|
||||
|
||||
# Check if the times are valid format
|
||||
if not (
|
||||
time_pattern.match(options[CONF_FETCH_TIME])
|
||||
and time_pattern.match(options[CONF_DAY_SWITCH_TIME])
|
||||
):
|
||||
errors["base"] = "time_format"
|
||||
else:
|
||||
if not time_pattern.match(options[CONF_FETCH_TIME]):
|
||||
errors[CONF_FETCH_TIME] = "time_format"
|
||||
if not time_pattern.match(options[CONF_DAY_SWITCH_TIME]):
|
||||
errors[CONF_DAY_SWITCH_TIME] = "time_format"
|
||||
if len(errors) == 0:
|
||||
return self.async_create_entry(title="", data=options)
|
||||
|
||||
return self.async_show_form(step_id="init", data_schema=SCHEMA, errors=errors)
|
||||
|
||||
@@ -480,7 +480,7 @@
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"time_format": "Please check the time fields. Times must be given in HH:MM format."
|
||||
"time_format": "Times must be given in HH:MM format."
|
||||
},
|
||||
"abort": {}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user