Field Overview

Learn about available field types for your models.

Types

Stacklane supports a wide variety of case-specific field types, including images and rich text.

In addition to custom model fields, every non-embedded model type is pre-defined with a unique id, plus created and modified timestamp fields. These fields are automatically managed, and all are available immediately after model creation, even prior to persisting.

Labels

When using models for forms, it's useful to define labels and descriptions for the field, which may then be used directly within HTML. By default all labels are assumed to be in the language of the Manifest locale.

/๐Ÿ“ฆ/๐ŸŒProduct.yaml
name:
  type: string
  label: Name
  placeholder: Product Name
  about: A great name for the product.

Even if not explicitly given, a default label is generated for every field using its name. "name" โ†’ "Name", "myField" โ†’ "My Field".

Option Labels

When using the options field type, each option is given a default label. To define custom labels for option values use the following name/value format:

status:
  type: options
  values:
    act: Active
    dis: Disabled

Metadata

Field labels and other field properties may be accessed statically, even when not using automatic form handling.

Example

<!--TEMPLATE mustache-->
{{% import {Product} from '๐Ÿ“ฆ' }}
<label>{{Product.name.label}}</label>

Properties

The following properties are available to all fields:

required

true if the field is required.

optional

true if the field is optional.

label

The custom label if defined, or a default label based on the field's name.

placeholder

The placeholder text if defined.

about

The about text if defined.

Unique Values

It is not recommended that an existing field be changed to unique after there is already live/production data for the field. A transaction will fail if trying to persist a duplicate unique value. If a unique value is being created or changed, first query by the unique field to check whether it's already used.

The string field type may be marked as unique: true for the Universal model type only. Unique values are constrained/scoped to the nearest container.

The uid field type is always unique (and retains previously used values).

Deleting a document will delete all associated unique values.

Within the directory "๐Ÿ“ฆ", and given a file name named ๐ŸŒArticle.yaml, a "Universal" model named Article will be available to your scripts.

Protected Fields

Protected fields have values which are intended to be handled with more care and thought than regular fields. Fields which may be protected are usually access tokens, identifiers, and other generated values.

A field may be marked as protected using protected: true

A protected field has the following properties:

  • Not available for direct access in Mustache (but may be exposed via suppliers).
  • Not available for use in forms, including custom forms (their input may not come directly from a user).
  • Available for direct access in server-side JavaScript, and exportable from suppliers as usual.