You are here

public function EnrollRequestDeclineForm::submitForm in Open Social 10.2.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/src/Form/EnrollRequestDeclineForm.php \Drupal\social_event\Form\EnrollRequestDeclineForm::submitForm()
  2. 10.3.x modules/social_features/social_event/src/Form/EnrollRequestDeclineForm.php \Drupal\social_event\Form\EnrollRequestDeclineForm::submitForm()
  3. 10.0.x modules/social_features/social_event/src/Form/EnrollRequestDeclineForm.php \Drupal\social_event\Form\EnrollRequestDeclineForm::submitForm()
  4. 10.1.x modules/social_features/social_event/src/Form/EnrollRequestDeclineForm.php \Drupal\social_event\Form\EnrollRequestDeclineForm::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

modules/social_features/social_event/src/Form/EnrollRequestDeclineForm.php, line 154

Class

EnrollRequestDeclineForm
Class EnrollRequestDeclineForm.

Namespace

Drupal\social_event\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if (!empty($this->eventEnrollment)) {
    $this->eventEnrollment->field_request_or_invite_status->value = EventEnrollmentInterface::REQUEST_OR_INVITE_DECLINED;
    $this->eventEnrollment
      ->save();
  }
  $this
    ->messenger()
    ->addStatus($this
    ->t('The enrollment request of @name has been declined.', [
    '@name' => $this->fullName,
  ]));
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}