Const

FIELD_SIGNAL_CONTEXT

@ng-forge/dynamic-forms

Injection token for providing field signal context to mappers and components.

The field signal context is the "nervous system" of the dynamic form library, providing access to: - The form instance and structure - Current form values (as signals) - Default values - Validation messages - The injector for creating components

This token is provided by the DynamicForm component and can be scoped for nested forms (Groups, Arrays) via child injectors.

Signature

const FIELD_SIGNAL_CONTEXT: InjectionToken<FieldSignalContext<Record<string, unknown>>>

Examples

// In a mapper function — prefer the helper for required access (descriptive error).
export function mapValueField(fieldDef: BaseValueField<any, any>): Binding[] {
  const context = injectFieldSignalContext();
  const form = context.form();
  // ... use context
}

// Optional access — token directly, returns null if not provided.
const ctx = inject(FIELD_SIGNAL_CONTEXT, { optional: true });
if (ctx) {
  // ...
}