fix format field vocabulary tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 11 Mar 2009 11:15:59 +0100
branchtls-sprint
changeset 1048 2a93712a6f8b
parent 1047 21d4d5e6aa45
child 1049 f8e92c2f3bef
fix format field vocabulary
web/form.py
--- a/web/form.py	Wed Mar 11 11:15:08 2009 +0100
+++ b/web/form.py	Wed Mar 11 11:15:59 2009 +0100
@@ -21,6 +21,7 @@
 from cubicweb.utils import ustrftime
 from cubicweb.selectors import yes, match_form_params, non_final_entity
 from cubicweb.view import NOINDEX, NOFOLLOW, View, EntityView, AnyRsetView
+from cubicweb.schema import FormatConstraint
 from cubicweb.common.registerers import accepts_registerer
 from cubicweb.common.uilib import toggle_action
 from cubicweb.web import stdmsgs
@@ -544,11 +545,15 @@
                 # if fckeditor is used and format field isn't explicitly
                 # deactivated, we want an hidden field for the format
                 widget = HiddenInput()
+                choices = None
             else:
                 # else we want a format selector
                 # XXX compute vocabulary
                 widget = Select
-            field = StringField(name=self.name + '_format', widget=widget)
+                req = form.req
+                choices = [(req._(format), format) for format in FormatConstraint().vocabulary(req=req)]
+            field = StringField(name=self.name + '_format', widget=widget,
+                                choices=choices)
             form.req.data[self] = field
             return field