Skip to content

Label

Show a read-only text in the form hardcoded in the xml form.

Simple example

<label string="This is an example" />
This is an example

With diferent sizes

<label string="This is a heading 1" widget_props='{"label_size": 1}' />

This is a heading 1

This is a heading 2

This is a heading 3

This is a heading 4

This is a heading 5

With diferent types

<label string="This is a success label"
widget_props="{'label_type': 'success'}" />
This is a success label
This is a warning label
This is a danger label
This is a secondary label

Combining size and type

<label string="This is a heading 1 success label"
widget_props='{"label_size": 1, "label_type": "success"}' />

This is a heading 1 success label

Dynamic label

<field name="name" widget="label"
widget_props="{'label_type': 'warning'}" />
This is a dynamic label

Showing a date in human readable format

v2.53.0

We can use the label widget to show a date in a human readable format.

<field name="date" widget="label" widget_props="{'human_date': true}"/>
2 years ago

API

PropertyDescriptionTypeDefaultVersion
stringContent for the labelstring--
alignAlignment of the labelleft | center | right--
widget_propsProps for the widget. See Widget propsobject--

Widget props

PropertyDescriptionTypeDefaultVersion
label_typeType of the labelsecondary | success | warning | dangerdefault-
label_sizeSize of the label1 | 2 | 3 | 4 | 5--
human_dateShow the date in human readable formatbooleanfalse v2.53.0