method

DateField.DefaultFrom

Use a callback to choose the initial date string when this field is omitted.

Arguments

ArgumentTypeDescription
callbackDefaultFunc[string]A non-nil function that receives operation.DefaultContext and returns an operation.Value[string] plus an error. Return Present(value) to supply a value, Empty to supply no default, or an error to stop the operation.

Returns

A new DateField with this callback as its only default. The original field is unchanged; this replaces any previous Default or DefaultFrom setting.

DateField

How it works

The callback runs on the server when omitted input is eligible for initialization. It does not prefill an unsaved form or refill a field on every edit. See the default values guide for new objects, repeated rows, and locales.

The returned string must match the field’s Format, such as DateOnly or DateTime.

Full signature

Related types

  • DateField

    DateField configures a field for a date, time, or timestamp.

  • DefaultFunc

    DefaultFunc supplies a server-side initial value for an eligible omitted field. Root and Siblings are snapshots at initialization; Prior is the persisted enclosing object or stable row (empty for new rows). ID may be empty. Locale is exact and Local retains authorization, cancellation and the active transaction. Present supplies a value, including zero values; Empty leaves it without a default. An error stops the operation. Returned values still pass validation. Defaults do not prefill an unsaved admin form and do not run on ordinary edits to an existing scope. Callbacks must not depend on other dynamic defaults or perform irreversible side effects: separate requests or retries can run again.

Related guides