1 The automatic entity form (:mod:`cubicweb.web.views.autoform`) |
1 The automatic entity form (:mod:`cubicweb.web.views.autoform`) |
2 --------------------------------------------------------------- |
2 --------------------------------------------------------------- |
3 |
3 |
|
4 Tags declaration |
|
5 ~~~~~~~~~~~~~~~~~~~~ |
|
6 |
4 It is possible to manage attributes/relations in the simple or multiple |
7 It is possible to manage attributes/relations in the simple or multiple |
5 editing form thanks to the following *rtags*: |
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 ~~~~~~~~~~~~~~~~~~~~ |
6 |
23 |
7 * `primary`, indicates that an attribute or a relation has to be |
24 * `primary`, indicates that an attribute or a relation has to be |
8 inserted **in the simple or multiple editing forms**. In the case of |
25 inserted **in the simple or multiple editing forms**. In the case of |
9 a relation, the related entity editing form will be included in the |
26 a relation, the related entity editing form will be included in the |
10 editing form and represented as a combobox. Each item of the |
27 editing form and represented as a combobox. Each item of the |
27 or other, and that it should not be displayed in the editing form. |
44 or other, and that it should not be displayed in the editing form. |
28 |
45 |
29 If necessary, it is possible to overwrite the method |
46 If necessary, it is possible to overwrite the method |
30 `relation_category(rtype, x='subject')` to dynamically compute |
47 `relation_category(rtype, x='subject')` to dynamically compute |
31 a relation editing category. |
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 |