You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[`pattern`](/spec/entities#fields)| an input-format regular expression enforced in the UI and server-side |
15
+
|[`defaultValue`](/spec/entities#defaultvalue-field-defaults)| a field default: column default, satisfies `required`, and seeds a new row in the UI |
15
16
|[`dependsOn`](/spec/relations)| link a dropdown to another, copy a value from the referenced record, or default a line from the open document header |
16
17
|[`function`](/spec/entities#function-the-presentation-role)| an explicit presentation role (Document, Setting, ...) |
17
18
|[`label`](/spec/entities#label-a-stored-display-name)| a stored, read-only display name for lookups |
Copy file name to clipboardExpand all lines: docs/spec/entities.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ fields:
37
37
| `required` | NOT NULL; the generated required-value validation keys on this. A field that also carries a default (`defaultValue`, or `init` on a relation) is NOT demanded from the caller - the default satisfies it |
38
38
| `length` | column length for string types |
39
39
| `pattern` | an input-format regular expression the value must match (string / text fields only) |
40
-
| `defaultValue` | column default |
40
+
| `defaultValue` | the field's default: the column default, the reason a `required` field is not demanded from the caller, and the value a **new** row is seeded with in the UI (see [Field defaults](#defaultvalue-field-defaults)) |
41
41
| `unique` | a UNIQUE constraint (e.g. a code or business key) |
| `readOnly` | rendered read-only in the UI (e.g. a calculated total) |
@@ -85,6 +85,28 @@ By default the generated UI controls follow declaration order - all fields first
85
85
86
86
Names match field / relation names (case-insensitive). A partial order is fine - any property not listed keeps its default position and is appended after the listed ones.
87
87
88
+
## defaultValue — field defaults
89
+
90
+
`defaultValue` states what a field holds when nobody supplies a value:
It has three effects at once, which are deliberately one key rather than three:
99
+
100
+
- it is the **column default**, so a row inserted without the column gets it;
101
+
- it **satisfies `required`**, so the caller is not asked for a value the model already guarantees;
102
+
- it **seeds a new row in the UI**, so an editor opens on the default instead of on a blank.
103
+
104
+
::: info Normative
105
+
A generator MUST apply the default when creating a new record and MUST NOT re-apply it to an existing one: a value the user cleared is a value the user chose, and re-defaulting it on the next edit would silently undo an intentional change. The default is a *starting value*, not a constraint — the user may replace it, and nothing revalidates a stored row against it. On a to-one relation the equivalent key is [`init`](/spec/relations), which names a seeded record.
106
+
:::
107
+
108
+
A default is what makes a bulk affordance one action rather than several: a dialog that creates one line per working day is only useful if the line it creates already carries the usual values.
0 commit comments