diff -r 058bb3dc685f -r 0b59724cb3f2 cubicweb/web/views/forms.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/web/views/forms.py Sat Jan 16 13:48:51 2016 +0100
@@ -0,0 +1,483 @@
+# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
+#
+# This file is part of CubicWeb.
+#
+# CubicWeb is free software: you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 2.1 of the License, or (at your option)
+# any later version.
+#
+# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with CubicWeb. If not, see .
+"""
+Base form classes
+-----------------
+
+.. Note:
+
+ Form is the glue that bind a context to a set of fields, and is rendered
+ using a form renderer. No display is actually done here, though you'll find
+ some attributes of form that are used to control the rendering process.
+
+Besides the automagic form we'll see later, there are roughly two main
+form classes in |cubicweb|:
+
+.. autoclass:: cubicweb.web.views.forms.FieldsForm
+.. autoclass:: cubicweb.web.views.forms.EntityFieldsForm
+
+As you have probably guessed, choosing between them is easy. Simply ask you the
+question 'I am editing an entity or not?'. If the answer is yes, use
+:class:`EntityFieldsForm`, else use :class:`FieldsForm`.
+
+Actually there exists a third form class:
+
+.. autoclass:: cubicweb.web.views.forms.CompositeForm
+
+but you'll use this one rarely.
+"""
+
+__docformat__ = "restructuredtext en"
+
+
+import time
+import inspect
+
+from six import text_type
+
+from logilab.common import dictattr, tempattr
+from logilab.common.decorators import iclassmethod, cached
+from logilab.common.textutils import splitstrip
+
+from cubicweb import ValidationError, neg_role
+from cubicweb.predicates import non_final_entity, match_kwargs, one_line_rset
+from cubicweb.web import RequestError, ProcessFormError
+from cubicweb.web import form
+from cubicweb.web.views import uicfg
+from cubicweb.web.formfields import guess_field
+
+
+class FieldsForm(form.Form):
+ """This is the base class for fields based forms.
+
+ **Attributes**
+
+ The following attributes may be either set on subclasses or given on
+ form selection to customize the generated form:
+
+ :attr:`needs_js`
+ sequence of javascript files that should be added to handle this form
+ (through :meth:`~cubicweb.web.request.Request.add_js`)
+
+ :attr:`needs_css`
+ sequence of css files that should be added to handle this form (through
+ :meth:`~cubicweb.web.request.Request.add_css`)
+
+ :attr:`domid`
+ value for the "id" attribute of the