You are here

public function ScheduleEmailWebformHandler::alterForm in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php \Drupal\webform_scheduled_email\Plugin\WebformHandler\ScheduleEmailWebformHandler::alterForm()

Alter webform submission form.

Parameters

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

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

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

Overrides WebformHandlerBase::alterForm

File

modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php, line 341

Class

ScheduleEmailWebformHandler
Schedules a webform submission's email.

Namespace

Drupal\webform_scheduled_email\Plugin\WebformHandler

Code

public function alterForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {

  // Display warning when test email will be sent immediately.
  if ($this->request
    ->isMethod('GET') && $this
    ->getWebform()
    ->isTest() && !empty($this->configuration['test_send'])) {
    $t_args = [
      '%label' => $this
        ->getLabel(),
    ];
    $form['scheduled_email_handler_test_send__' . $this
      ->getHandlerId()] = [
      '#type' => 'webform_message',
      '#message_message' => $this
        ->t('The %label email will be sent immediately upon submission.', $t_args),
      '#message_type' => 'warning',
      '#message_close' => TRUE,
      '#weight' => -100,
    ];
  }
}