doc/book/en/development/devweb/views/autoform.rst
branchstable
changeset 5266 84f285d96363
parent 4256 bf6e0e75acfa
child 5314 86e5abbebfaf
equal deleted inserted replaced
5265:97ab2ea6d367 5266:84f285d96363
       
     1 The automatic entity form (:mod:`cubicweb.web.views.autoform`)
       
     2 ---------------------------------------------------------------
       
     3 
       
     4 Tags declaration
       
     5 ~~~~~~~~~~~~~~~~~~~~
       
     6 
       
     7 It is possible to manage attributes/relations in the simple or multiple
       
     8 editing form thanks of the methods bellow ::
       
     9 
       
    10   uicfg.autoform_section.tag_subject_of(<relation>, tag)
       
    11   uicfg.autoform_section.tag_object_of(<relation>, tag)
       
    12   uicfg.autoform_field.tag_attribute(<attribut_def>, tag)
       
    13 
       
    14 Where ``<relation>`` is a three elements tuple ``(Subject Entity Type,
       
    15 relation_type, Object Entity Type)``. ``<attribut_def>`` is a two elements tuple
       
    16 ``(Entity Type, Attribut Name)``. Wildcard ``*`` could be used in place of
       
    17 ``Entity Type``
       
    18 
       
    19 Possible tags are detailled below
       
    20 
       
    21 Simple Tags
       
    22 ~~~~~~~~~~~~~~~~~~~~
       
    23 
       
    24 * `primary`, indicates that an attribute or a relation has to be
       
    25   inserted **in the simple or multiple editing forms**. In the case of
       
    26   a relation, the related entity editing form will be included in the
       
    27   editing form and represented as a combobox. Each item of the
       
    28   combobox is a link to an existing entity.
       
    29 
       
    30 * `secondary`, indicates that an attribute or a relation has to be
       
    31   inserted **in the simple editing form only**. In the case of a
       
    32   relation, the related entity editing form will be included in the
       
    33   editing form and represented as a combobox. Each item of the combobox
       
    34   is a link to an existing entity.
       
    35 
       
    36 * `inlineview`, includes the target entity's form in the editing form
       
    37   of the current entity. It allows to create the target entity in the
       
    38   same time as the current entity.
       
    39 
       
    40 * `generic`, indicates that a relation has to be inserted in the simple
       
    41   editing form, in the generic box of relation creation.
       
    42 
       
    43 * `generated`, indicates that an attribute is dynamically computed
       
    44   or other,  and that it should not be displayed in the editing form.
       
    45 
       
    46 If necessary, it is possible to overwrite the method
       
    47 `relation_category(rtype, x='subject')` to dynamically compute
       
    48 a relation editing category.
       
    49 
       
    50 
       
    51 Advanced Tags
       
    52 ~~~~~~~~~~~~~~~~~~~~
       
    53 
       
    54 Tag can also reference a custom Field crafted with the help of
       
    55 ``cubicweb.web.formfields`` and ``cubicweb.web.formwidget``. In the example
       
    56 bellow, the field ``path`` of ``ExecData`` entities will be done with a standard
       
    57 file input dialogue ::
       
    58 
       
    59   from cubicweb.web import uicfg, formfields, formwidgets
       
    60 
       
    61   uicfg.autoform_field.tag_attribute(('Execdata', 'path'),
       
    62       formfields.FileField(name='path', widget=formwidgets.FileInput()))
       
    63 
       
    64 
       
    65 
       
    66 
       
    67 
       
    68 
       
    69