Fields

The h3 and div tags use the t-field attribute. The value of the t-field attribute must be used with the recordset having a length of one, this allows the user to change the content of the web page when the user opens the website in edit mode. When you save the page, updated values will be stored in the database. Of course, this is subject to a permission check and is only allowed if the current user has write permissions on the displayed record. With an optional t-options attribute, you can give a dictionary option to be passed to the field renderer, including the widget to be used. Currently, there is not a vast amount of widgets for the backend, so the choices are a bit limited here. For example, if you want to display an image from the binary field, then you can use the image widget like this:

<span t-field="author.image_small" t-options="{'widget': 'image'}"/>

t-field has some limitations. It only works on recordsets and it cannot work on the <t> element. For this, you need to use some HTML elements, like <span> or <div>. There is an alternative of the t-field attribute, which is t-esc. The t-esc attribute is not limited to recordsets; it can also be used on any data types, but it is not editable in a website.

Another difference between t-esc and t-field is that t-field shows values based on the user's language, while t-esc shows raw values from the database. For example, for users who configured the English language in their preferences and set the datetime field as used with t-field, then the result will be rendered in the 12/15/2018 17:12:13 format. In contrast, if the t-esc attribute is used, then the result will in a rendered format, like this: 2018-12-15 16:12:13.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset