FieldTypeDefinition
@ng-forge/dynamic-forms
Configuration interface for registering custom field types.
Defines how a field type should be handled by the dynamic form system, including its component loading strategy and field-to-component mapping logic. Supports both eager-loaded and lazy-loaded components.
Signature
interface FieldTypeDefinition<
T extends FieldDef<any> = any
>Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
T | FieldDef<any> | any | The field definition type this field type handles |
Properties
| Name | Type | Description |
|---|---|---|
name | string | Unique identifier for the field type |
_fieldDef ? | T | undefined | Field definition type marker (internal use) |
loadComponent ? | LazyComponentLoader | undefined | Function to load the component (supports lazy loading). Returns a Promise that resolves to the component class or module with default export. Optional - omit for componentless fields (e.g., hidden fields) that only contribute to form values without rendering any UI. |
mapper ? | MapperFn<T> | undefined | Mapper function that converts field definition to component bindings. Optional - omit for componentless fields (like hidden fields) that don't need input mapping. When omitted for componentless fields (no loadComponent), an empty signal is returned. When omitted for regular fields with a component, falls back to baseFieldMapper. |
valueHandling ? | ValueHandlingMode | undefined | How this field type handles form values and data collection (defaults to 'include') |
propsToMeta ? | string[] | undefined | List of prop keys to forward to the meta object. Some props (like Note: Meta values always take precedence over forwarded props. |
scope ? | FieldScope | FieldScope[] | undefined | Semantic scope for tooling to discover interchangeable field alternatives |
renderReadyWhen ? | readonly RenderReadyInput[] | undefined | Mapped component inputs that must exist before the renderer instantiates the component |
addons ? | FieldAddonSupport | undefined | Declares which addon slots this field accepts and (optionally) the subset of kinds allowed. Source of truth for the runtime addon validator. Field types that
omit this property are treated as Tier 3 — any |
Examples
const CustomInputType: FieldTypeDefinition<InputFieldDef> = {
name: 'custom-input',
loadComponent: () => import('./custom-input.component').then(m => m.CustomInputComponent),
mapper: customInputMapper
};
// Register with providers
provideDynamicForm(CustomInputType)packages/dynamic-forms/src/lib/models/field-type.ts:56