civi.afform.input_types¶
Summary¶
This Symfony event is dispatched by Civi\Afform\Utils when building the catalogue of field input widgets for FormBuilder. It allows developers to register custom field input components or alter existing input templates.
Definition¶
This event is dispatched via the Symfony EventDispatcher.
public static function onAfformInputTypes(\Civi\Core\Event\GenericHookEvent $event): void
Parameters¶
\Civi\Core\Event\GenericHookEvent $event
Event Properties¶
Since this event uses GenericHookEvent, properties are accessed dynamically:
$event->inputTypes:array- Reference to associative array of input types, keyed by type name (e.g.'text','select','wysiwyg'). Each input type definition supports:module:string- Angular module defining the runtime directive/template (defaults to'af').admin_module:string- Angular module defining the GUI editor directive/template (defaults to'afGuiEditor').template:string- HTML template path for client rendering (e.g.'~/af/fields/text.html').admin_template:string- HTML template path for FormBuilder GUI rendering (e.g.'~/afGuiEditor/inputType/text.html').
Availability¶
- Available since CiviCRM 6.15
Example¶
use Civi\Core\Event\GenericHookEvent;
public static function onAfformInputTypes(GenericHookEvent $event): void {
$event->inputTypes['colorpicker'] = [
'module' => 'myModule',
'admin_module' => 'myModule',
'template' => '~/myModule/fields/colorpicker.html',
'admin_template' => '~/myModule/inputType/colorpicker.html',
];
}