28 .. sourcecode:: python |
28 .. sourcecode:: python |
29 |
29 |
30 # Adds all subjects of the entry_of relation in the add menu of the ``Blog`` primary view |
30 # Adds all subjects of the entry_of relation in the add menu of the ``Blog`` primary view |
31 uicfg.actionbox_appearsin_addmenu.tag_object_of(('*', 'entry_of', 'Blog'), True) |
31 uicfg.actionbox_appearsin_addmenu.tag_object_of(('*', 'entry_of', 'Blog'), True) |
32 |
32 |
33 |
|
34 |
|
35 Automatic form configuration |
|
36 ```````````````````````````` |
|
37 |
|
38 Attributes/relations display location |
|
39 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
40 |
|
41 ``uicfg.autoform_section`` specifies where to display a relation in |
|
42 creation/edition entity form for a given form type. ``tag_attribute``, |
|
43 ``tag_subject_of`` and ``tag_object_of`` methods for this relation tag expect |
|
44 two arguments additionally to the relation key: a ``formtype`` and a |
|
45 ``section``. |
|
46 |
|
47 formtype may be one of: |
|
48 |
|
49 * ``main``, the main entity form (via the modify action) |
|
50 * ``inlined``, the form for an entity inlined into another form |
|
51 * ``muledit``, the table form to edit multiple entities |
|
52 |
|
53 section may be one of: |
|
54 |
|
55 * ``hidden``, don't display |
|
56 |
|
57 * ``attributes``, display in the attributes section |
|
58 |
|
59 * ``relations``, display in the relations section, using the generic relation |
|
60 selector combobox (available in main form only, and not for attribute |
|
61 relation) |
|
62 |
|
63 * ``inlined``, display target entity of the relation in an inlined form |
|
64 (available in main form only, and not for attribute relation) |
|
65 |
|
66 * ``metadata``, display in a special metadata form (NOT YET IMPLEMENTED, subject |
|
67 to changes) |
|
68 |
|
69 By default, mandatory relations are displayed in the ``attributes`` section, |
|
70 others in ``relations`` section. |
|
71 |
|
72 Change default fields |
|
73 ^^^^^^^^^^^^^^^^^^^^^ |
|
74 |
|
75 Use ``autoform_field`` to replace the default field type of an attribute. |
|
76 |
|
77 .. Warning: |
|
78 ``autoform_field_kwargs`` should usually be used instead of |
|
79 ``autoform_field``. Do not use both methods for the same relation! |
|
80 |
|
81 |
|
82 Customize field options |
|
83 ^^^^^^^^^^^^^^^^^^^^^^^ |
|
84 |
|
85 In order to customize field options (see :class:`cubicweb.web.formfields.Field` |
|
86 for a detailed list of options), use ``autoform_field_kwargs``. This rtag takes |
|
87 a relation triplet and a dictionary as arguments. |
|
88 |
|
89 .. sourcecode:: python |
|
90 |
|
91 # Change the content of the combobox |
|
92 # here ``ticket_done_in_choices`` is a function which returns a list of |
|
93 # elements to populate the combobox |
|
94 uicfg.autoform_field_kwargs.tag_subject_of(('Ticket', 'done_in', '*'), {'sort': False, |
|
95 'choices': ticket_done_in_choices}) |
|
96 |
|
97 |
|
98 |
|
99 Overriding permissions |
|
100 ^^^^^^^^^^^^^^^^^^^^^^ |
|
101 |
|
102 ``autoform_permissions_overrides`` provides a way to by-pass security checking |
|
103 for dark-corner case where it can't be verified properly. XXX documents. |
|
104 |
33 |
105 """ |
34 """ |
106 __docformat__ = "restructuredtext en" |
35 __docformat__ = "restructuredtext en" |
107 |
36 |
108 from warnings import warn |
37 from warnings import warn |