# HG changeset patch # User Alain Leufroy # Date 1432131187 -7200 # Node ID 8e04ab5582d9c79f206e7a1a57525296e4105e31 # Parent 523a7f09806622293359982f7acf19b915737000 [web/views/formrenderer] do not use `cubicweb:target` attribute on form (closes #5534074) The `cubicweb:target` is a flag indicating that the form data (with file input) shall be posted inside an iframe - this is a well known "ajax-like" workaround to post files with browsers that do not support `FormData` (a.k.a IE<10). The `cubicweb:target` was introduced when CW used the "xhtml strict" doctype. Now that CW uses the "html5" doctype, this namespaced attribute is no longer necessary and the iframe can be generated directly. Before this patch, CW inserts the `cubicweb:target` attribute in the form DOM element (server side) and `setFormsTarget()` updates the DOM with a new ` @@ -259,36 +260,13 @@ The form validation process --------------------------- -Preparation -~~~~~~~~~~~ - -After the (html) document is loaded, the ``setFormsTarget`` javascript -function dynamically transforms the DOM as follows. For all forms of -the DOM, it: - -* sets the ``target`` attribute where there is a ``cubicweb:target`` - attribute (with the same value) - -* appends an empty `IFRAME` element at the end - -Let us have a look again at the form element. We have omitted some -irrelevant attributes. - -.. sourcecode::html - -
- ... -
- Validation loop ~~~~~~~~~~~~~~~ On form submission, the form.action is invoked. Basically, the ``validateform`` controller is called and its output lands in the -specified ``target``, the iframe that was previously prepared. +specified ``target``, an invisible `` """, - 'long_desc': """
<not specified>
+ 'long_desc': """
<not specified>
@@ -126,9 +127,10 @@
+
""", - 'manager': """
<not specified>
+ 'manager': """
<not specified>
@@ -162,6 +164,7 @@
+
""", 'composite_card11_2ttypes': """<not specified>""", 'concerns': """<not specified>""" diff -r 523a7f098066 -r 8e04ab5582d9 web/views/formrenderers.py --- a/web/views/formrenderers.py Fri Jul 25 17:10:05 2014 +0200 +++ b/web/views/formrenderers.py Wed May 20 16:13:07 2015 +0200 @@ -196,7 +196,7 @@ if form.cssclass: attrs.setdefault('class', form.cssclass) if form.cwtarget: - attrs.setdefault('cubicweb:target', form.cwtarget) + attrs.setdefault('target', form.cwtarget) if not form.autocomplete: attrs.setdefault('autocomplete', 'off') return '
' % uilib.sgml_attributes(attrs) @@ -206,7 +206,13 @@ for form renderers overriding open_form to use something else or more than and """ - return u'
' + out = u'' + if form.cwtarget: + attrs = {'name': form.cwtarget, 'id': form.cwtarget, + 'width': '0px', 'height': '0px', + 'src': 'javascript: void(0);'} + out = (u'\n' % uilib.sgml_attributes(attrs)) + out + return out def render_fields(self, w, form, values): fields = self._render_hidden_fields(w, form) diff -r 523a7f098066 -r 8e04ab5582d9 web/views/forms.py --- a/web/views/forms.py Fri Jul 25 17:10:05 2014 +0200 +++ b/web/views/forms.py Wed May 20 16:13:07 2015 +0200 @@ -95,7 +95,7 @@ value for the "style" attribute of the
tag :attr:`cwtarget` - value for the "cubicweb:target" attribute of the tag + value for the "target" attribute of the tag :attr:`redirect_path` relative to redirect to after submitting the form