dynamic-forms / Function

withEventFormValue

Enables automatic form value attachment to all events dispatched through the EventBus.

When this feature is enabled, events dispatched via eventBus.dispatch() will include the current form value in the formValue property. This is useful for event handlers that need access to the complete form state at the time of the event.

Notes

Precedence rules:

  1. Per-form false - Disables for this form, regardless of global setting
  2. Per-form true - Enables for this form, regardless of global setting
  3. Per-form undefined - Uses global setting
  4. Global withEventFormValue() - Enables globally
  5. No global feature - Disabled globally (default)

Presentation

function withEventFormValue(): DynamicFormFeature<"event-form-value">;

Returns

DynamicFormFeature<"event-form-value"> -

A DynamicFormFeature that enables form value attachment to events

Example usage

Global opt-in

Consumer usage

eventBus.on<SubmitEvent>('submit').subscribe(event => {
  if (hasFormValue(event)) {
    console.log('Form value:', event.formValue);
  }
});

Per-form disable (when globally enabled)

const config: FormConfig = {
  fields: [...],
  options: { emitFormValueOnEvents: false }
};