[form fields] nicer behaviour of the password field: don't put internal field value on edition (triggering validation error if one validation without removing the value, due to confirmation mismatch), and don't show the field as required in such case stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 18 Feb 2010 11:08:00 +0100
branchstable
changeset 4628 2f23148d0870
parent 4627 54de0ddd0bf3
child 4629 1eeef3cbf528
[form fields] nicer behaviour of the password field: don't put internal field value on edition (triggering validation error if one validation without removing the value, due to confirmation mismatch), and don't show the field as required in such case
web/formfields.py
--- a/web/formfields.py	Thu Feb 18 11:06:40 2010 +0100
+++ b/web/formfields.py	Thu Feb 18 11:08:00 2010 +0100
@@ -413,12 +413,17 @@
 
 class PasswordField(StringField):
     widget = fw.PasswordInput
+    def form_init(self, form):
+        if self.eidparam and form.edited_entity.has_eid():
+            # see below: value is probably set but we can't retreive it. Ensure
+            # the field isn't show as a required field on modification
+            self.required = False
 
     def typed_value(self, form, load_bytes=False):
         if self.eidparam:
             # no way to fetch actual password value with cw
             if form.edited_entity.has_eid():
-                return INTERNAL_FIELD_VALUE
+                return ''
             return self.initial_typed_value(form, load_bytes)
         return super(PasswordField, self).typed_value(form, load_bytes)