Appearance
Controls
Controls are the visual representation of parts of forms, usually associated with form fields.
They are identified by name which can include a namespace (colon separated as in ae:my-example
).
Controls are documents of type control-form
and consist of a template, style, and controller script.
When a field is defined in a form and no explicit control name is specified, the control name is derived from the field type. For example, a field of type select
will use the control select
.
Usage
Controls are most often used inside the form definition (which is defined as FormDown). The control name is put into a styling directive in front of a fields label or fields definition.
Styling directives are enclosed in curly braces {}
and can contain multiple key-value pairs separated by |
. The key-value pairs are separated by =
. The key is the name of the parameter and the value is the value of the parameter. If the value contains spaces, it must be enclosed in quotes. Multiple styling directives can be put right after each other.
If the first key is not followed by a =
, the value is assumed to be either a built-in styling tag or the control name to use.
formdown
// A simple text field. This will use the control `text`
[Name][name]
// A number field. This will use the control `number`
[Age][age]
[age]: number
// The `hidden` directive is built-in and will hide the field. It is part of a small group of built-in directives.
{hidden}
[Height][height]
// Render any occurrence of `height` as a number field with a unit of cm. This will use the control `number`.
// The only exception is any label that has explicitly overridden the control.
[height]: number <unit=cm>
// A standalone control. This will use the control custom-control
// Rendering a field with a different control. This will use the control my:custom-control
where my
must match the // namespace of the control and custom-control
is the name of the control. {my:custom-control another-param="value"} [Name][name]
Built-In Styling Directives
The following built-in styling directives are available:
hidden
andhide
: Hides the field.show
: Shows the field (only makes sense in combination withif
).readonly
: Makes the field read-only.editable
: Makes the field editable (only makes sense in combination withif
).
The can be used with if
to conditionally show or hide fields.
formdown
[Show Field][showField]
[showField]: Switch
// A field that is only shown if the field `showField` is true
{show if showField}
[Another Field][anotherField]
[Show other Field][showOtherField]
[showOtherField]: Select
- FIRST: First
- SECOND: Second
// A field that is only shown if the field `showOtherField` is `FIRST`
{show if showOtherField=='FIRST'}
[Yet Another Field][yetAnotherField]
Lookup Rules
As controls are identified by name, the lookup rules are are more complex than for layouts, but similar to designs.
Controls can be limited as to which types of fields they support, which cardinality, or standalone mode. These are checked when a control matching the namespace and name is found.
The search inside control folders are always sorted by
created.at
date, so in case of multiple controls with the same name, the one created first is used.
The lookup rules are as follows:
- If the form of the document being rendered has a child document of type
control-form
with matching name (and namespace), then that document is used as the control. - With the Form of the document as a starting point, we look for a folder on each level to each successive parent with the type
control-folder
and look for a child document of typecontrol-form
matching the controls namespace and name.- If the current ancestor we investigate is a
form-folder
, we look through any referencedcontrol-folder
from the styling section of the folder. - If the current ancestor we investigate is an
application-form
, we look through any referencedcontrol-folder
from the styling section of the application. - If we reached the root we look through any referenced
control-folder
from the styling section of root.
- If the current ancestor we investigate is a
- Then we lookup the control in the System Control folder (
controls-folder
) of the system folder - If there is nothing found still we ignore the name of the control and use the default control for the field type from the
default
folder in the system control folder
Lookup Graph
This flowchart visually represents the lookup rules for controls.