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 | Field definition type marker (internal use) |
loadComponent ? | LazyComponentLoader | 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> | 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 | How this field type handles form values and data collection (defaults to 'include') |
propsToMeta ? | string[] | 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[] | Semantic scope for tooling to discover interchangeable field alternatives |
renderReadyWhen ? | RenderReadyInput[] | Mapped component inputs that must exist before the renderer instantiates the component |
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:55