restore possibility to have default value methods on forms, this may still be useful according to how the form is defined stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 19 May 2009 09:06:42 +0200
branchstable
changeset 1855 4e2eeb88780f
parent 1854 9302d0e66076
child 1856 b0a6e34ba11b
restore possibility to have default value methods on forms, this may still be useful according to how the form is defined
web/form.py
--- a/web/form.py	Tue May 19 09:05:47 2009 +0200
+++ b/web/form.py	Tue May 19 09:06:42 2009 +0200
@@ -378,10 +378,10 @@
 
     def form_field_value(self, field, load_bytes=False):
         """return field's *typed* value"""
-        value = field.initial
-        if callable(value):
-            value = value(self)
-        return value
+        myattr = '%s_%s_default' % (field.role, field.name)
+        if hasattr(self, myattr):
+            return getattr(self, myattr)()
+        return field.initial
 
     def form_field_error(self, field):
         """return validation error for widget's field, if any"""