diff --git a/owrx/controllers/settings/__init__.py b/owrx/controllers/settings/__init__.py index 8ad8a4e8..0ac3c5de 100644 --- a/owrx/controllers/settings/__init__.py +++ b/owrx/controllers/settings/__init__.py @@ -20,6 +20,7 @@ class SettingsFormController(AuthorizationMixin, BreadcrumbMixin, WebpageControl super().__init__(handler, request, options) self.errors = {} self.globalError = None + self.formData = None @abstractmethod def getSections(self): @@ -35,8 +36,18 @@ class SettingsFormController(AuthorizationMixin, BreadcrumbMixin, WebpageControl def getErrors(self): return self.errors + def buildRenderData(self): + # this basially builds an intermediate result to be rendered + # relevant when the form has to be displayed again due to errors + # in this specific scenario, we mix the config with the data the user already submitted + # we use a copy of the config so that whatever we apply here does not get accidentally stored + res = self.getData().__dict__() + if self.formData is not None: + self._applyConfigData(res, self.formData) + return res + def render_sections(self): - sections = "".join(section.render(self.getData(), self.getErrors()) for section in self.getSections()) + sections = "".join(section.render(self.buildRenderData(), self.getErrors()) for section in self.getSections()) buttons = self.render_buttons() return """