civi.afform_admin.metadata¶
Summary¶
This Symfony event is dispatched to alter metadata for the FormBuilder GUI. It allows developers to add or customize entities, elements, styles, permissions, date ranges, and search display tags in the editor interface.
Definition¶
This event is dispatched via the Symfony EventDispatcher.
public static function onAfformAdminMetadata(\Civi\Core\Event\GenericHookEvent $event): void
Parameters¶
\Civi\Core\Event\GenericHookEvent $event
Event Properties¶
Since this event uses GenericHookEvent, properties are accessed dynamically:
$event->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)submissionTokens(array: optional list of tokens usable in redirect URLs or confirmation screens).$event->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'.$event->styles:array- Bootstrap style strings available in the GUI.$event->permissions:array- Permissions that can be set for an Afform.$event->dateRanges:array- Date range options.$event->searchDisplayTags:array- Tags for filtering search displays.
[!NOTE] Form field input widgets are configured via
civi.afform.input_types. Regarding entitysubmissionTokens, check the form processor extension for an example implementation: see the event listener in form-processor.
Availability¶
- Available since CiviCRM 5.50
Example¶
use Civi\Core\Event\GenericHookEvent;
public static function onAfformAdminMetadata(GenericHookEvent $event): void {
// Add a custom style option to the GUI editor
$event->styles[] = 'my-custom-form-class';
}