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 ?T | undefinedField 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 | undefinedHow 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 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[] | undefinedSemantic scope for tooling to discover interchangeable field alternatives
renderReadyWhen ?readonly RenderReadyInput[] | undefinedMapped 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 addons configured on such a field are dropped with a warning at config init.

Examples

const CustomInputType: FieldTypeDefinition<InputFieldDef> = {
  name: 'custom-input',
  loadComponent: () => import('./custom-input.component').then(m => m.CustomInputComponent),
  mapper: customInputMapper
};

// Register with providers
provideDynamicForm(CustomInputType)