dynamic-forms / Function

resolveTokens

Resolves special tokens in event arguments to their actual values

Supported tokens:

  • $key: The current field key
  • $index: The array index (if inside an array field)
  • $arrayKey: The parent array field key (if inside an array field)
  • formValue: Reference to the current form value for indexing

Presentation

function resolveTokens(
  args: readonly (string | number | boolean | null | undefined)[],
  context: TokenContext,
): unknown[];

Returns

unknown[] -

Array with resolved values

Parameters

NameTypeDescription
args
readonly (string | number | boolean | null | undefined)[]

Array of arguments that may contain tokens

context
TokenContext

Context object containing token values

Example usage

resolveTokens(['$arrayKey', '$index'], { arrayKey: 'contacts', index: 2 }) // Returns: ['contacts', 2]

resolveTokens(['$key', 'static'], { key: 'myField' }) // Returns: ['myField', 'static']