Skip to main content

Variables

This document describes all the variables available in the Tera template context when rendering form templates.

info

If you are running into issues trying to access some variables you can always print all the available variables in you current context with the magical variable : __tera_context (use {{ __tera_context | debug }} for more visibility).

warning

This documentation was created from the mobile tera context. We do our best to maintain the same context on mobile and web but there may be discrepancies. If your template only works on one of the plateforms, please notify us so we can update the context if necessary.

Available Variables

form_instance

Represents the current form instance being rendered.

Type: MobileFormInstance

Properties:

  • uuid (UUID): Unique identifier of the form instance
  • form_id (integer): ID of the associated form
  • made_at (integer, optional): Timestamp when instance was created (in seconds)
  • created_at (integer): Creation timestamp (in seconds)
  • progression (integer): Completion percentage (0-100)
  • started_at (integer, optional): When the form was first started (in seconds)
  • linked_event (UUID, optional): Associated event identifier
  • created_by (integer): User ID who created the instance
  • client_company_uuid (UUID, optional): Associated company identifier
  • updated_at (integer): Last update timestamp (in seconds)

Example

{{ form_instance.uuid }}
{{ form_instance.progression }}%
{% if form_instance.started_at %}Started at: {{ form_instance.started_at }}{% endif %}

field_values

Array of all field values for the current form instance.

Type: Array<WasmFieldValue>

Properties per item:

  • uuid (UUID): Unique identifier of the field value
  • form_instance_id (UUID): Associated form instance ID
  • id (integer): Field ID
  • metadata (object): Additional metadata for the field
  • value (any, optional): The actual field value
  • type_ (string): Field type (e.g., "company", "user", "image", etc.)
  • name (string): Field name
  • slug (string): Field slug identifier

Example

{% for uuid, value in field_values | group_by(attribute="metadata.product") %}
{% set my_slug = value | filter(attribute="slug", value="my-slug") | first %}
{% if my_slug %}
{{ my_slug.value }}
{% endif %}
{% endfor %}

{% set company_fields = field_values | filter(attribute="type_", value="company") %}

client_company

Information about the associated client company (if any).

Type: WasmCompany

Properties:

  • uuid (UUID): Company unique identifier
  • created_by (integer): User ID who created the company
  • owner_id (integer): Company owner user ID
  • company_name (string): Company name
  • company_website (string, optional): Website URL
  • company_email (string, optional): Contact email
  • company_logo (string, optional): Logo image path
  • company_phone (string, optional): Phone number
  • company_billing_address (string, optional): Billing address
  • company_billing_post_code (string, optional): Billing postal code
  • company_billing_city (string, optional): Billing city
  • company_billing_country (string, optional): Billing country
  • status_id (integer, optional): Status ID
  • images (string, optional): Associated images
  • created_at (integer): Creation timestamp
  • updated_at (integer, optional): Last update timestamp
  • latitude (float, optional): GPS latitude
  • longitude (float, optional): GPS longitude
  • status_name (string): Status display name
  • parent_name (string, optional): Parent company name
  • owner_name (string): Owner's name
  • owner_photo (string, optional): Owner's photo path

Example

<h1>{{ client_company.company_name }}</h1>
<p>Owner: {{ client_company.owner_name }}</p>
{% if client_company.company_website %}
<a href="{{ client_company.company_website }}">Website</a>
{% endif %}

products

HashMap of all available products indexed by UUID.

Type: HashMap<UUID, WasmProduct>

Properties per product:

  • uuid (UUID): Product unique identifier
  • name (string): Product name
  • description (string, optional): Product description
  • summary (string, optional): Product summary
  • price (float, optional): Product price
  • user_id (integer): User who created the product
  • category (integer, optional): Category ID
  • brand (integer, optional): Brand ID
  • reference (string): Product reference
  • barcode (string): Product barcode
  • code_upc (string): UPC code
  • stock (integer, optional): Available stock
  • tax (float, optional): Tax rate
  • status_id (integer, optional): Status ID
  • outer (integer, optional): Outer packaging quantity
  • images (string, optional): Associated images
  • created_at (integer): Creation timestamp
  • updated_at (integer, optional): Last update timestamp
  • width (float, optional): Product width
  • height (float, optional): Product height
  • depth (float, optional): Product depth

Example

{% for uuid, product in products %}
<div>
<h3>{{ product.name }}</h3>
<p>Price: {{ product.price }}</p>
<p>Stock: {{ product.stock | default: "N/A" }}</p>
</div>
{% endfor %}

user

Information about the user who created the form instance.

Type: WasmUser (optional)

Properties:

  • id (integer): User ID
  • name (string): User full name
  • photo (string, optional): Profile photo path
  • email (string): Email address
  • phone (string, optional): Phone number

Example

{% if user %}
Created by: {{ user.name }} ({{ user.email }})
{% if user.photo %}
<img src="{{ user.photo }}" alt="{{ user.name }}">
{% endif %}
{% endif %}

company_promo

Promotions that apply to the current company.

Type: Array<WasmPromotion>

Properties per promotion:

  • id (integer): Promotion ID
  • name (string): Promotion name
  • description (string, optional): Promotion description
  • periods (object): Active periods configuration
  • is_active (boolean): Whether promotion is currently active
  • products (array): Associated products
  • companies (array): Associated companies
  • fields (array): Associated form fields

Example

{% if company_promo %}
<h3>Available Promotions</h3>
{% for promo in company_promo %}
{% if promo.is_active %}
<div>{{ promo.name }}</div>
{% endif %}
{% endfor %}
{% endif %}

promotions

All available promotions in the system.

Type: Array<WasmPromotion>

Same structure as company_promo but includes all promotions regardless of company association.

Example

<select name="promotion">
{% for promo in promotions %}
<option value="{{ promo.id }}">{{ promo.name }}</option>
{% endfor %}
</select>

assortments

Available product catalogues/assortments.

Type: Array<WasmAssortment>

Properties per assortment:

  • id (integer): Assortment ID
  • name (string): Assortment name

Example

{% for assortment in assortments %}
<div>{{ assortment.name }}</div>
{% endfor %}

form_fields

All available form fields in the system.

Type: Array<WasmFormFields>

Properties per field:

  • id (integer): Field ID
  • name (string): Field display name
  • data (string, optional): Field configuration data
  • type_ (string): Field type
  • slug (string): Field slug identifier
  • is_company (boolean): Whether field is company-related
  • is_form (boolean): Whether field is form-related
  • is_additional (boolean): Whether field is additional
  • is_product (boolean): Whether field is product-related
  • constraint (string, optional): Field constraints
  • is_promotion (boolean): Whether field is promotion-related

Example

{% set company_fields = form_fields | filter(attribute="is_company", value=true) %}
{% for field in company_fields %}
<label for="{{ field.slug }}">{{ field.name }}</label>
{% endfor %}

form_template

Current form template information.

Type: WasmFormTemplate

Properties:

  • id (integer): Template ID
  • name (string): Template name
  • screens (object): Screen configuration

Example

<h1>{{ form_template.name }}</h1>
<!-- Access screen configuration -->
{{ form_template.screens.welcome_screen.title }}

resolved_images

HashMap mapping image hashes to resolved image paths.

Type: HashMap<String, WasmResolvedImage>

Properties per image:

  • thumb (string): Thumbnail image path
  • original (string): Original image path

Example

{% for hash, image in resolved_images %}
<img src="{{ image.thumb }}" onclick="showOriginal('{{ image.original }}')" alt="Image">
{% endfor %}

lua_values

Custom values passed from Lua scripts (optional).

Type: Value (optional)

This variable contains any custom data structure passed from Lua scripts and can vary depending on the implementation.

Example

{% if lua_values %}
{{ lua_values.custom_field }}
{% endif %}

additional_columns

Configuration for additional database columns.

Type: Array<Object>

Properties per column:

  • id (integer): Column ID
  • name (string): Column name
  • type (string): Column data type
  • data (object): Column configuration
  • field_id (integer, optional): Associated field ID

Example

{% for column in additional_columns %}
{% if column.field_id %}
Additional data for field {{ column.field_id }}: {{ column.name }}
{% endif %}
{% endfor %}

client_company_additional_columns

Additional column values for the current company (optional).

Type: Array<Object> (optional)

Properties per value:

  • additional_column_id (integer): Column ID
  • value (object): Column value

Example

{% if client_company_additional_columns %}
{% for col_value in client_company_additional_columns %}
Column {{ col_value.additional_column_id }}: {{ col_value.value }}
{% endfor %}
{% endif %}

brands

Available product brands.

Type: Array<Object>

Properties per brand:

  • id (integer): Brand ID
  • name (string): Brand name
  • description (string, optional): Brand description

Example

<select name="brand">
{% for brand in brands %}
<option value="{{ brand.id }}">{{ brand.name }}</option>
{% endfor %}
</select>

Usage Tips

Accessing Nested Data

Many variables contain nested objects or arrays. Use dot notation to access nested properties:

{{ client_company.owner_name }}
{{ form_instance.created_at }}

Filtering and Iteration

Use Tera's built-in filters and control structures to work with arrays:

{% set image_fields = field_values | filter(attribute="type_", value="image") %}
{% for field in image_fields %}
{% if field.value %}
<!-- Display images -->
{% endif %}
{% endfor %}

Conditional Rendering

Check for existence and values before using optional fields:

{% if client_company.company_logo %}
<img src="{{ client_company.company_logo }}" alt="Company Logo">
{% endif %}

{% if form_instance.progression == 100 %}
<p>Form completed!</p>
{% endif %}

Working with Timestamps

Timestamps are provided in seconds since Unix epoch:

{% if form_instance.started_at %}
Started: {{ form_instance.started_at | date(format="%Y-%m-%d %H:%M") }}
{% endif %}