Instantiate initial form values when form is instantiated (at startup)
authorKarl O. Pinc <kop@karlpinc.com>
Fri, 22 Jan 2021 19:14:16 +0000 (13:14 -0600)
committerKarl O. Pinc <kop@karlpinc.com>
Fri, 22 Jan 2021 19:14:16 +0000 (13:14 -0600)
src/pgwui_core/core.py

index e6696396e7aca67147e2328a40ab67f3820d1b05..d8d487c4c181542dca2cfa9c687c1d35f8704964 100644 (file)
@@ -187,6 +187,7 @@ class LoadedForm(collections.abc.MutableMapping):
             store.update(kwargs)
         self._store = store
         self._fc = fc
+        self.ivals = fc.ivals(self.uh.request.registry.settings)
 
     def __iter__(self):
         for item in self._store:
@@ -215,8 +216,7 @@ class LoadedForm(collections.abc.MutableMapping):
         if post:
             self._form = self._fc(formdata=post)
         else:
-            ivals = self._fc.ivals(self.uh.request.registry.settings)
-            self._form = self._fc(obj=ivals)
+            self._form = self._fc(obj=self.ivals)
 
     def write(self, response, errors):
         '''