Skip to content

Commit

Permalink
retain user input after an error (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodpayne authored Aug 15, 2021
1 parent 13a80e6 commit d288b70
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion custom_components/integration_blueprint/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ async def async_step_user(self, user_input=None):

return await self._show_config_form(user_input)

user_input = {}
# Provide defaults for form
user_input[CONF_USERNAME] = ""
user_input[CONF_PASSWORD] = ""

return await self._show_config_form(user_input)

@staticmethod
Expand All @@ -56,7 +61,10 @@ async def _show_config_form(self, user_input): # pylint: disable=unused-argumen
return self.async_show_form(
step_id="user",
data_schema=vol.Schema(
{vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str}
{
vol.Required(CONF_USERNAME, default=user_input[CONF_USERNAME]): str,
vol.Required(CONF_PASSWORD, default=user_input[CONF_PASSWORD]): str,
}
),
errors=self._errors,
)
Expand Down

0 comments on commit d288b70

Please sign in to comment.