should use a hidden text area for error description, not an hidden input (else the browser may remove line breaks) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 06 Jul 2009 10:32:28 +0200
branchstable
changeset 2270 70c0da0f2181
parent 2269 0d1b7206fdc9
child 2271 5483155a1e17
should use a hidden text area for error description, not an hidden input (else the browser may remove line breaks)
web/views/forms.py
web/views/management.py
--- a/web/views/forms.py	Mon Jul 06 09:44:53 2009 +0200
+++ b/web/views/forms.py	Mon Jul 06 10:32:28 2009 +0200
@@ -119,8 +119,8 @@
 
     def form_add_hidden(self, name, value=None, **kwargs):
         """add an hidden field to the form"""
-        field = StringField(name=name, widget=fwdgs.HiddenInput, initial=value,
-                            **kwargs)
+        kwargs.setdefault('widget', fwdgs.HiddenInput)
+        field = StringField(name=name, initial=value, **kwargs)
         if 'id' in kwargs:
             # by default, hidden input don't set id attribute. If one is
             # explicitly specified, ensure it will be set
--- a/web/views/management.py	Mon Jul 06 09:44:53 2009 +0200
+++ b/web/views/management.py	Mon Jul 06 10:32:28 2009 +0200
@@ -14,7 +14,7 @@
 from cubicweb.selectors import yes, none_rset, match_user_groups, authenticated_user
 from cubicweb.view import AnyRsetView, StartupView, EntityView
 from cubicweb.common.uilib import html_traceback, rest_traceback
-from cubicweb.web import formwidgets
+from cubicweb.web import formwidgets as wdgs
 from cubicweb.web.formfields import guess_field
 
 SUBMIT_MSGID = _('Submit bug report')
@@ -110,7 +110,7 @@
         form = self.vreg.select_object('forms', 'base', self.req, entity=entity,
                                        form_renderer_id='base',
                                   submitmsg=msg,
-                                  form_buttons=[formwidgets.SubmitButton()],
+                                  form_buttons=[wdgs.SubmitButton()],
                                   domid='ownership%s' % entity.eid,
                                   __redirectvid='security',
                                   __redirectpath=entity.rest_path())
@@ -167,7 +167,7 @@
         newperm.eid = self.req.varmaker.next()
         w(u'<p>%s</p>' % _('add a new permission'))
         form = self.vreg.select_object('forms', 'base', self.req, entity=newperm,
-                                       form_buttons=[formwidgets.SubmitButton()],
+                                       form_buttons=[wdgs.SubmitButton()],
                                        domid='reqperm%s' % entity.eid,
                                        __redirectvid='security',
                                        __redirectpath=entity.rest_path())
@@ -177,7 +177,7 @@
         cwpermschema = newperm.e_schema
         if permnames is not None:
             field = guess_field(cwpermschema, self.schema.rschema('name'),
-                                widget=formwidgets.Select({'size': 1}),
+                                widget=wdgs.Select({'size': 1}),
                                 choices=permnames)
         else:
             field = guess_field(cwpermschema, self.schema.rschema('name'))
@@ -247,15 +247,17 @@
             form = self.vreg.select_object('forms', 'base', self.req, rset=None,
                                            mainform=False)
             binfo = text_error_description(ex, excinfo, req, eversion, cversions)
-            form.form_add_hidden('description', binfo)
+            form.form_add_hidden('description', binfo,
+                                 # we must use a text area to keep line breaks
+                                 widget=wdgs.TextArea({'class': 'hidden'}))
             form.form_add_hidden('__bugreporting', '1')
             if submitmail:
-                form.form_buttons = [formwidgets.SubmitButton(MAIL_SUBMIT_MSGID)]
+                form.form_buttons = [wdgs.SubmitButton(MAIL_SUBMIT_MSGID)]
                 form.action = req.build_url('reportbug')
                 w(form.form_render())
             if submiturl:
                 form.form_add_hidden('description_format', 'text/rest')
-                form.form_buttons = [formwidgets.SubmitButton(SUBMIT_MSGID)]
+                form.form_buttons = [wdgs.SubmitButton(SUBMIT_MSGID)]
                 form.action = submiturl
                 w(form.form_render())