diff -r cb5dfea92285 -r b6e250dd7a7d web/views/forms.py --- a/web/views/forms.py Fri Apr 23 11:10:30 2010 +0200 +++ b/web/views/forms.py Fri Apr 23 12:42:53 2010 +0200 @@ -1,9 +1,32 @@ -"""some base form classes for CubicWeb web client +# organization: Logilab +# copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. +# contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr +# license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses +""" +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. -:organization: Logilab -:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. -:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr -:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses +Besides the automagic form we'll see later, they are barely two 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" @@ -16,43 +39,77 @@ from cubicweb import typed_eid from cubicweb.selectors import non_final_entity, match_kwargs, one_line_rset from cubicweb.web import uicfg, form, formwidgets as fwdgs -from cubicweb.web.formfields import StringField, relvoc_unrelated, guess_field +from cubicweb.web.formfields import relvoc_unrelated, guess_field class FieldsForm(form.Form): - """base class for fields based forms. + """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: - * `needs_js`: sequence of javascript files that should be added to handle - this form (through `req.add_js`) + :attr:`needs_js` + sequence of javascript files that should be added to handle this form + (through :meth:`~cubicweb.web.request.Request.add_js`) - * `needs_css`: sequence of css files that should be added to handle this - form (through `req.add_css`) + :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