You are here

public function EmailWebformHandler::resendMessageForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformHandler/EmailWebformHandler.php \Drupal\webform\Plugin\WebformHandler\EmailWebformHandler::resendMessageForm()

Build resend message webform.

Parameters

array $message: An array of message parameters.

Return value

array A webform to edit a message.

Overrides WebformHandlerMessageInterface::resendMessageForm

File

src/Plugin/WebformHandler/EmailWebformHandler.php, line 1266

Class

EmailWebformHandler
Emails a webform submission.

Namespace

Drupal\webform\Plugin\WebformHandler

Code

public function resendMessageForm(array $message) {
  $element = [];
  $element['to_mail'] = [
    '#type' => 'webform_email_multiple',
    '#title' => $this
      ->t('To email'),
    '#default_value' => $message['to_mail'],
  ];
  $element['cc_mail'] = [
    '#type' => 'webform_email_multiple',
    '#title' => $this
      ->t('CC email'),
    '#default_value' => $message['cc_mail'],
  ];
  $element['bcc_mail'] = [
    '#type' => 'webform_email_multiple',
    '#title' => $this
      ->t('BCC email'),
    '#default_value' => $message['bcc_mail'],
  ];
  $element['from_divider'] = [
    '#markup' => '<hr/>',
  ];
  $element['from_mail'] = [
    '#type' => 'webform_email_multiple',
    '#title' => $this
      ->t('From email'),
    '#required' => TRUE,
    '#default_value' => $message['from_mail'],
  ];
  $element['from_name'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('From name'),
    '#required' => TRUE,
    '#default_value' => $message['from_name'],
  ];
  $element['message_divider'] = [
    '#markup' => '<hr/>',
  ];
  $element['subject'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Subject'),
    '#default_value' => $message['subject'],
  ];
  $element['body'] = [
    '#type' => $message['html'] ? 'webform_html_editor' : 'webform_codemirror',
    '#title' => $this
      ->t('Message'),
    '#required' => TRUE,
    '#default_value' => $message['body'],
  ];
  $element['reply_to'] = [
    '#type' => 'value',
    '#value' => $message['reply_to'],
  ];
  $element['return_path'] = [
    '#type' => 'value',
    '#value' => $message['return_path'],
  ];
  $element['html'] = [
    '#type' => 'value',
    '#value' => $message['html'],
  ];
  $element['attachments'] = [
    '#type' => 'value',
    '#value' => $message['attachments'],
  ];
  if ($message['attachments']) {
    $element['files'] = [
      '#type' => 'item',
      '#title' => $this
        ->t('Attachments'),
    ] + $this
      ->buildAttachments($message['attachments']);
  }

  // Preload HTML Editor and CodeMirror so that they can be properly
  // initialized when loaded via Ajax.
  $element['#attached']['library'][] = 'webform/webform.element.html_editor';
  $element['#attached']['library'][] = 'webform/webform.element.codemirror.text';
  return $element;
}