API reference > @kontsedal/olas-core > createField
createField() function
A reactive form field owned by this controller's lifetime (§8.1).
ts
const email = createField<string>(ctx, '', { validators: [required('Required')] })T is inferred from initial. With validators, a literal such as '' stays literal (Field<''>), so name the type as above.
A free function rather than a ctx method, so a controller that never builds a field does not ship the forms subsystem.
Signature:
typescript
export declare function createField<T>(ctx: Ctx, initial: T, options?: FieldOptions<T>): Field<T>;Parameters
Parameter | Type | Description |
|---|---|---|
ctx | ||
initial | T | |
options | FieldOptions<T> | (Optional) |
Returns:
Field<T>