type
DefaultContext
The request and surrounding values available to a field’s dynamic default callback.
Context properties
| Property | Type | Description |
|---|---|---|
Context | context.Context | Cancellation and deadline for this operation. Pass ctx.Context to ctx.Local.FindByID. |
Operation | Kind | The document action, such as Create or Duplicate. It can be Update when an edit adds a new object, row, or translation; a default callback does not imply a new document. |
Actor | Actor | The signed-in document, its auth collection, and a snapshot of its fields. Actor.ID is empty for an anonymous request; Actor is a value, not a pointer. |
Locale | schema.LocaleCode | The exact content locale being initialized, or an empty string without localization. Locale fallback is not treated as stored input. |
Root | View | Root document fields available at this point. Values may be incomplete or not yet validated; do not expect results from other dynamic defaults. |
Siblings | View | Fields in the same enclosing object or row. For seo.title, this is seo; for a title at the document root, this is Root. It has the same timing limits as Root. |
Prior | View | Previously saved fields in the same enclosing object or row, matched by stable row key. Empty for a new nested object, row, or translation. During duplication the root can contain source values, while copied rows with new keys have no prior row. |
Local | Reader | Read a known document with FindByID. Reads enforce this actor’s access rules, use the exact locale without fallback, and share the active transaction and cancellation. This reader cannot write documents. |
ID | ID | The document identifier. It may still be empty before a newly created document receives an ID. |
CollectionID | schema.StableID | The collection’s framework identifier, not its authored slug. Empty for a global. |
GlobalID | schema.StableID | The global’s framework identifier, not its authored slug. Empty for a collection. |
AllLocales | bool | Whether Root retains locale-keyed values. A visit to one exact localized value receives false. |
OccurrenceID | OccurrenceID | An opaque identifier for this field value, including stable row keys and the exact locale. Most callbacks do not need it; do not parse it or build one from an array index. |
SchemaOccurrenceID | OccurrenceID | An opaque identifier grouping the same configured field across rows and locales. Most callbacks can use Siblings instead of tracking this identifier. |
How it works
Ridu supplies this context to DefaultFrom callbacks. Read Root, Siblings, and Prior as snapshots; changing a local copy does not change the document. Return Present(value) from the callback to supply this field’s initial value.
View.String, View.Get, and View.Lookup accept one direct child name. Read a nested object before looking up its child; passing "seo.title" does not traverse the object.
A default sees values at initialization, not the completed candidate passed to a validator. Use request information or already available input, and avoid dependencies between dynamic defaults.