civi.afform.createToken¶
Summary¶
This Symfony event is dispatched by Civi\Afform\Tokens when generating token links to an Afform page (for instance, when building an email token linking to an Afform with contextual arguments). It allows entities and behaviors to inspect the token row context and append custom arguments to the Afform link query string.
Definition¶
This event is dispatched via the Symfony EventDispatcher.
public static function onAfformCreateToken(\Civi\Core\Event\GenericHookEvent $event): void
Parameters¶
\Civi\Core\Event\GenericHookEvent $event
Event Properties¶
Since this event uses GenericHookEvent, properties are accessed dynamically:
$event->row:\Civi\Token\TokenRow- The current token row object providing contextual entities (e.g.$row->context['contactId'],$row->context['activityId']).$event->afformArgs:array- Reference to associative array of arguments that will be appended to the generated Afform link URL (e.g.['activity_id' => $id]).
Availability¶
- Available since CiviCRM 6.9
Example¶
use Civi\Core\Event\GenericHookEvent;
public static function onAfformCreateToken(GenericHookEvent $event): void {
$row = $event->row;
if (!empty($row->context['caseId'])) {
$event->afformArgs['case_id'] = $row->context['caseId'];
}
}