method
EmailField.DefaultFrom
Use a callback to choose the initial email address when this field is omitted.
Arguments
| Argument | Type | Description |
|---|---|---|
callback | DefaultFunc[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 EmailField with this callback as its only default. The original field is unchanged; this replaces any previous Default or DefaultFrom setting.
EmailFieldHow 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 still pass email validation.
Full signature
func (f EmailField) DefaultFrom(callback DefaultFunc[string]) EmailFieldRelated types
EmailFieldEmailField configures a field that stores and validates an email address.
DefaultFuncChoose a field’s initial value on the server using the request, user, locale, or nearby values.