Interface

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

NameConstraintDefaultDescription
TFieldDef<any>anyThe field definition type this field type handles

Properties

NameTypeDescription
name stringUnique identifier for the field type
_fieldDef ?TField 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 ?ValueHandlingModeHow 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 type for inputs, rows/cols for textareas) are actually native HTML attributes. Specifying them here causes them to be merged into the meta object before being passed to the component, ensuring they're applied via the meta tracking mechanism.

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)