web/formfields.py
branchtls-sprint
changeset 1147 402e8a8b1d6a
parent 1108 1e5ed5f57f2f
child 1181 620ec8e6ae19
--- a/web/formfields.py	Thu Mar 26 18:58:14 2009 +0100
+++ b/web/formfields.py	Thu Mar 26 18:59:01 2009 +0100
@@ -307,7 +307,7 @@
         return RelationField(widget=Select(multiple=card in '*+'), **kwargs)
         
     def vocabulary(self, form):
-        entity = form.entity
+        entity = form.edited_entity
         req = entity.req
         # first see if its specified by __linkto form parameters
         linkedto = entity.linked_to(self.name, self.role)
@@ -334,8 +334,8 @@
     field = None
     for cstr in constraints:
         if isinstance(cstr, StaticVocabularyConstraint):
-            return StringField(widget=Select(vocabulary=cstr.vocabulary),
-                               **kwargs)
+            kwargs.setdefault('widget', Select(vocabulary=cstr.vocabulary))
+            return StringField(**kwargs)
         if isinstance(cstr, SizeConstraint) and cstr.max is not None:
             if cstr.max > 257:
                 rows_cols_from_constraint(cstr, kwargs)
@@ -375,7 +375,8 @@
         if fieldclass is StringField:
             if targetschema == 'Password':
                 # special case for Password field: specific PasswordInput widget
-                return StringField(widget=PasswordInput(), **kwargs)
+                kwargs.setdefault('widget', PasswordInput())
+                return StringField(**kwargs)
             if eschema.has_metadata(rschema, 'format'):
                 # use RichTextField instead of StringField if the attribute has
                 # a "format" metadata. But getting information from constraints