Events
FormBuilder Events¶
civi.afform_admin.metadata¶
Alter metadata for the FormBuilder GUI
Since: CiviCRM 5.50
Type: GenericHookEvent
Params:
entities(array) List of entities that can be used in the FormBuilder 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 Editorafform_type(array) Form types this element is used forelement(array) Default markup for this elementdirective(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.submissionTokens(array) List of tokens which can be used in the confirmation screen or redirect url after the user submitted the form. To return the token values the Save action of your entity should return this as fields. Each item has array keys:token(string) Name of the token.label(string) The label of the token.description(string) Optional a description of the token.
Note
Regarding the submissionTokens. Check the form processor extension for an implemantion. Here is the implementation of the event listener civi.afform_admin.metadata
And here is the implementation of the API4 Save action which returns the token values.
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)