doc/book/en/development/devweb/views/autoform.rst
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Fri, 16 Apr 2010 17:00:49 +0200
branchstable
changeset 5314 86e5abbebfaf
parent 5266 84f285d96363
permissions -rw-r--r--
[doc/book] refresh the autoform section with uicfg content (moved there)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
     1
The automatic entity form
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
     2
-------------------------
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
     3
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
     4
(:mod:`cubicweb.web.views.autoform`)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     5
4256
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
     6
Tags declaration
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
     7
````````````````
4256
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
     8
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     9
It is possible to manage attributes/relations in the simple or multiple
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    10
editing form using proper uicfg tags.
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    11
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    12
.. sourcecode:: python
4256
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    13
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    14
  uicfg.autoform_section.tag_subject_of(<relation>, tag)
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    15
  uicfg.autoform_section.tag_object_of(<relation>, tag)
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    16
  uicfg.autoform_field.tag_attribute(<attribut_def>, tag)
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    17
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    18
The details of the uicfg syntax can be found in the :ref:`uicfg`
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    19
chapter.
4256
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    20
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    21
Possible tags are detailled below
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    22
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    23
Automatic form configuration
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    24
````````````````````````````
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    25
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    26
Attributes/relations display location
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    27
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    28
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    29
``uicfg.autoform_section`` specifies where to display a relation in
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    30
creation/edition entity form for a given form type.  ``tag_attribute``,
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    31
``tag_subject_of`` and ``tag_object_of`` methods for this relation tag expect
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    32
two arguments additionally to the relation key: a ``formtype`` and a
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    33
``section``.
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    34
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    35
``formtype`` may be one of:
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    36
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    37
* ``main``, the main entity form (via the modify action)
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    38
* ``inlined``, the form for an entity inlined into another form
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    39
* ``muledit``, the table form to edit multiple entities
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    40
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    41
section may be one of:
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    42
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    43
* ``hidden``, don't display
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    44
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    45
* ``attributes``, display in the attributes section
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    46
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    47
* ``relations``, display in the relations section, using the generic relation
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    48
  selector combobox (available in main form only, and not for attribute
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    49
  relation)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    50
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    51
* ``inlined``, display target entity of the relation in an inlined form
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    52
  (available in main form only, and not for attribute relation)
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    53
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    54
* ``metadata``, display in a special metadata form (NOT YET IMPLEMENTED, subject
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    55
  to changes)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    56
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    57
By default, mandatory relations are displayed in the ``attributes`` section,
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    58
others in ``relations`` section.
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    59
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    60
Change default fields
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    61
^^^^^^^^^^^^^^^^^^^^^
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    62
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    63
Use ``autoform_field`` to replace the default field type of an attribute.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    64
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    65
.. warning::
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    66
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    67
   ``autoform_field_kwargs`` should usually be used instead of
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    68
   ``autoform_field``. Do not use both methods for the same relation!
4256
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    69
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    70
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    71
Customize field options
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    72
^^^^^^^^^^^^^^^^^^^^^^^
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    73
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    74
In order to customize field options (see :class:`cubicweb.web.formfields.Field`
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    75
for a detailed list of options), use ``autoform_field_kwargs``. This rtag takes
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    76
a relation triplet and a dictionary as arguments.
4256
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    77
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    78
.. sourcecode:: python
4256
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    79
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    80
   # Change the content of the combobox
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    81
   # here ``ticket_done_in_choices`` is a function which returns a list of
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    82
   # elements to populate the combobox
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    83
   uicfg.autoform_field_kwargs.tag_subject_of(('Ticket', 'done_in', '*'), {'sort': False,
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    84
                                                  'choices': ticket_done_in_choices})
4256
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    85
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    86
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    87
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    88
Overriding permissions
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    89
^^^^^^^^^^^^^^^^^^^^^^
4256
bf6e0e75acfa import uicfg.auto_form doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2172
diff changeset
    90
5314
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    91
``autoform_permissions_overrides`` provides a way to by-pass security checking
86e5abbebfaf [doc/book] refresh the autoform section with uicfg content (moved there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
    92
for dark-corner case where it can't be verified properly. XXX documents.