Skip to content

Events

Form Builder Events

civi.afform_admin.metadata

Alter metadata for the Form Builder GUI

Since: CiviCRM 5.50

Type: GenericHookEvent

Params:

  • entities (array) List of entities that can be used in the Form Builder GUI. Each item has array keys:
  • name (string)
  • label (string)
  • icon (string:"fa-*")
  • type (string:"primary"|"secondary")
  • defaults (string:js object).
  • elements (array) Static elements that can be added to a form, keyed by name. Each item has array keys:
  • title (string) Title shown in Editor
  • afform_type (array) Form types this element is used for
  • element (array) Default markup for this element
  • directive (string) Specify directive name in dash format (should match ['element']['#tag'])
  • admin_tpl (string) Editor template. Extensions can provide their own template for editing this element type, by adding an Angular module with base page 'civicrm/admin/afform'.
  • inputTypes (array) Form widgets used to represent a field.
  • styles (array) Bootstrap3 style strings.
  • permissions (array) Permissions that can be set for an Afform.
  • dateRanges (array) Date range options.

civi.afform.prefill

Prefill entity data when the form is being viewed.

Since: CiviCRM 5.56

Type: AfformPrefillEvent

Methods:

  • getAfform(): array
  • getFormDataModel(): Civi\Afform\FormDataModel
  • getApiRequest(): Civi\Api4\Action\Afform\Prefill
  • getEntityType(): string
  • getEntityName(): string
  • getSecureApi4(): callable
  • setEntityId(int $index, int $id)
  • setJoinIds(int $index, string $joinEntity, array $joinIds)

civi.afform.validate

Validate submission of an Afform.

Since: CiviCRM 5.56

Type: AfformValidateEvent

Methods:

  • getAfform(): array
  • getFormDataModel(): Civi\Afform\FormDataModel
  • getApiRequest(): Civi\Api4\Action\Afform\Submit
  • getEntityValues(): array
  • setError(string $errorMsg)

civi.afform.submit

Handle submission of an <af-form> entity (or set of entities in the case of <af-repeat>).

Since: CiviCRM 5.31

Type: AfformSubmitEvent

Methods:

  • getAfform(): array
  • getFormDataModel(): Civi\Afform\FormDataModel
  • getApiRequest(): Civi\Api4\Action\Afform\Submit
  • getEntityType(): string
  • getEntityName(): string
  • getRecords(): array
  • getSecureApi4(): callable
  • setEntityId(int $index, int $id)
  • setRecords(array $records)
  • setJoinIds(int $index, string $joinEntity, array $joinIds)