From 2e642ed48de7a01f0c96856c335c118796fe2e9e Mon Sep 17 00:00:00 2001 From: Jens Schuppe Date: Wed, 21 Feb 2024 14:30:58 +0100 Subject: [PATCH] Use form ID depending on route context --- .../src/Controller/RegisterFormController.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/civiremote_event/src/Controller/RegisterFormController.php b/modules/civiremote_event/src/Controller/RegisterFormController.php index e078a14..563d613 100644 --- a/modules/civiremote_event/src/Controller/RegisterFormController.php +++ b/modules/civiremote_event/src/Controller/RegisterFormController.php @@ -126,7 +126,7 @@ public function form(RouteMatch $route_match, string $context, stdClass $event, } // Retrieve implementation for building the form. - $form_id = $this->getFormId($profile); + $form_id = $this->getFormId($profile, $context); // Build the form. return $this->formBuilder()->getForm( @@ -156,9 +156,20 @@ public function title(stdClass $event) { return $event->event_title; } - private function getFormId($profile = NULL) { + private function getFormId($profile = NULL, string $context = 'create') { // Use generic form ID. - $form_id = '\Drupal\civiremote_event\Form\RegisterForm'; + switch ($context) { + case 'create': + $form_id = '\Drupal\civiremote_event\Form\RegisterForm'; + break; + case 'update': + $form_id = '\Drupal\civiremote_event\Form\RegistrationUpdateForm'; + break; + case 'cancel': + $form_id = '\Drupal\civiremote_event\Form\RegistrationCancelForm'; + break; + } + // Try to find a profile-specific implementation. if ($profile) {