[forms] fix RelationField bug with pending eids (eg inlined forms): we have to override process_form_value to avoid caching when recomputing is needed stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 15 Feb 2010 15:18:38 +0100
branchstable
changeset 4581 c92ded4dee20
parent 4580 9fce32b5d219
child 4582 d12b81facd1d
[forms] fix RelationField bug with pending eids (eg inlined forms): we have to override process_form_value to avoid caching when recomputing is needed
web/formfields.py
--- a/web/formfields.py	Mon Feb 15 15:17:24 2010 +0100
+++ b/web/formfields.py	Mon Feb 15 15:18:38 2010 +0100
@@ -816,6 +816,18 @@
     def format_single_value(self, req, value):
         return value
 
+    def process_form_value(self, form):
+        """process posted form and return correctly typed value"""
+        try:
+            return form.formvalues[self]
+        except KeyError:
+            value = self._process_form_value(form)
+            # if value is None, there are some remaining pending fields, we'll
+            # have to recompute this later -> don't cache in formvalues
+            if value is not None:
+                form.formvalues[self] = value
+            return value
+
     def _process_form_value(self, form):
         """process posted form and return correctly typed value"""
         widget = self.get_widget(form)