98d4a4de67ee0a846de15f472ce09f6eb8548922
[odoo/odoo.git] / doc / form-notes.rst
1 Notes on the usage of the Form View as a sub-widget
2 ===================================================
3
4 Undocumented stuff
5 ------------------
6
7 * ``initial_mode`` *option* defines the starting mode of the form
8   view, one of ``view`` and ``edit`` (?). Default value is ``view``
9   (non-editable form).
10
11 * ``embedded_view`` *attribute* has to be set separately when
12   providing a view directly, no option available for that usage.
13
14   * View arch **must** contain node with
15     ``@class="oe_form_container"``, otherwise everything will break
16     without any info
17
18   * Root element of view arch not being ``form`` may or may not work
19     correctly, no idea.
20
21   * Freeform views => ``@version="7.0"``
22
23 * Form is not entirely loaded (some widgets may not appear) unless
24   ``on_record_loaded`` is called (or ``do_show``, which itself calls
25   ``on_record_loaded``).
26
27 * "Empty" form => ``on_button_new`` (...), or manually call
28   ``default_get`` + ``on_record_loaded``
29
30 * Form fields default to width: 100%, padding, !important margin, can
31   be reached via ``.oe_form_field``
32
33 * Form *will* render buttons and a pager, offers options to locate
34   both outside of form itself (``$buttons`` and ``$pager``), providing
35   empty jquery objects (``$()``) seems to stop displaying both but not
36   sure if there are deleterious side-effects.
37
38   Other options:
39
40   * Pass in ``$(document.createDocumentFragment)`` to ensure it's a
41     DOM-compatible tree completely outside of the actual DOM.
42
43   * ???
44
45 * readonly fields probably don't have a background, beware if need of
46   overlay
47
48   * What is the difference between ``readonly`` and
49     ``effective_readonly``?
50
51 * No facilities for DOM events handling/delegations e.g. handling
52   keyup/keydown/keypress from a form fields into the form's user.
53
54   * Also no way to reverse from a DOM node (e.g. DOMEvent#target) back to a
55     form view field easily