summaryrefslogtreecommitdiff
path: root/doc/reference
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2020-07-02 11:52:07 +0000
committerAaron Bohy <aab@odoo.com>2020-07-02 13:57:37 +0000
commite17dc1a793817c535863d2e3e40754468d140fb8 (patch)
tree7978e66ef4df645c1c8a3c416475e7ee365a34d9 /doc/reference
parent25258e314e3a6fc97c072d5b7cb4236ac4fd5b01 (diff)
[IMP] web: form: labels of several occurrences of a field
Before this commit, when the same field occurred multiple times in a form view, all occurrences were associated with the same id, and all occurrences of the corresponding label (if any) had the same 'for' attribute. As a consequence, besides the fact that there were warnings in the chrome console, clicking on any occurrence of the duplicated label focuses the first occurrence of the field. This commit generates a unique id for each pair label/field, when possible. However, there is a case that can't be handled automatically: when the label isn't automatically generated (field located outside a group, or with nolabel attribute set to "1"). Typically, in this case, there is a <label> node with "for" attribute referencing the associated field. In this situation, the id must be defined in the arch, and used in the "for" attribute: <form> <label for="phone"/><field name="phone"/> <label for="phone_2"/><field name="phone" id="phone_2"/> </form> Task 2261697
Diffstat (limited to 'doc/reference')
-rw-r--r--doc/reference/views.rst24
1 files changed, 24 insertions, 0 deletions
diff --git a/doc/reference/views.rst b/doc/reference/views.rst
index 97d96fb7062..ee91fea5934 100644
--- a/doc/reference/views.rst
+++ b/doc/reference/views.rst
@@ -800,6 +800,9 @@ system. Available semantic components are:
``name`` (mandatory)
the name of the field to render
+ ``id``
+ the node id. Useful when there are several occurrences of the same field in
+ the view (see ``label`` component below). Default is the field name.
``widget``
fields have a default rendering based on their type
(e.g. :class:`~odoo.fields.Char`,
@@ -871,6 +874,27 @@ system. Available semantic components are:
for opening specific kanban view when selecting records from m2o/m2m in mobile
environment
+``label``
+ when a ``field`` component isn't placed directly inside a ``group``, or when
+ its ``nolabel`` attribute is set, the field's label isn't automatically
+ displayed alongside its value. The ``label`` component is the manual alternative
+ of displaying the label of a field. Possible attributes are:
+ ``for`` (mandatory)
+ the reference to the field associated with the label. Can be either the name
+ of a field, or its id (``id`` attribute set on the ``field``). When there are
+ several occurrences of the same field in the view, and there are several
+ ``label`` components associated with these ``field`` nodes, those labels
+ must have unique ``for`` attributes (in this case referencing the ``id``
+ attribute of the corresponding ``field`` nodes).
+ ``string``
+ the label to display. Display the field's label (coming from the field
+ definition in the model) by default.
+ ``class``
+ same as for ``field`` component.
+ ``attrs``
+ same as for ``field`` component.
+
+
Generic structure
~~~~~~~~~~~~~~~~~