dynamic-forms / Class

AddArrayItemEvent

Implements:FormEvent

Event dispatched to add a new item to an array field.

This event is used to dynamically add items to array fields at runtime. The array field component listens for this event and adds a new item based on the provided field template, or uses the array's own template if not provided.

Constructor

No documentation has been provided.

Presentation
constructor(
	readonly arrayKey: string, 
	readonly field?: ArrayAllowedChildren | undefined, 
	readonly index?: number | undefined
): AddArrayItemEvent;
Parameters
NameTypeDescription
r
arrayKey
string
r
field
ArrayAllowedChildren | undefined
r
index
number | undefined

Properties

NameTypeDescription
type
r
implements FormEvent
"add-array-item"

Example usage

// Add item using array's own template
eventBus.dispatch(AddArrayItemEvent, 'contacts');

// Add item with explicit field template
const fieldTemplate = { key: 'email', type: 'input' };
eventBus.dispatch(AddArrayItemEvent, 'contacts', fieldTemplate);

// Add item at specific index
eventBus.dispatch(AddArrayItemEvent, 'contacts', fieldTemplate, 2);