public function EmailYamlFormHandler::resendMessageForm in YAML Form 8
Build resend message form.
Parameters
array $message: An array of message parameters.
Return value
array A form to edit a message.
Overrides YamlFormHandlerMessageInterface::resendMessageForm
File
- src/
Plugin/ YamlFormHandler/ EmailYamlFormHandler.php, line 600
Class
- EmailYamlFormHandler
- Emails a form submission.
Namespace
Drupal\yamlform\Plugin\YamlFormHandlerCode
public function resendMessageForm(array $message) {
$element = [];
$element['to_mail'] = [
'#type' => 'yamlform_email_multiple',
'#title' => $this
->t('To email'),
'#default_value' => $message['to_mail'],
];
$element['from_mail'] = [
'#type' => 'yamlform_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['subject'] = [
'#type' => 'textfield',
'#title' => $this
->t('Subject'),
'#default_value' => $message['subject'],
];
$body_format = $this->configuration['html'] ? 'html' : 'text';
$element['body'] = [
'#type' => 'yamlform_codemirror',
'#mode' => $body_format,
'#title' => $this
->t('Message (@format)', [
'@format' => $this->configuration['html'] ? $this
->t('HTML') : $this
->t('Plain text'),
]),
'#rows' => 10,
'#required' => TRUE,
'#default_value' => $message['body'],
];
$element['html'] = [
'#type' => 'value',
'#value' => $message['html'],
];
$element['attachments'] = [
'#type' => 'value',
'#value' => $message['attachments'],
];
// Display attached files.
if ($message['attachments']) {
$file_links = [];
foreach ($message['attachments'] as $attachment) {
$file_links[] = [
'#theme' => 'file_link',
'#file' => $attachment['file'],
'#prefix' => '<div>',
'#suffix' => '</div>',
];
}
$element['files'] = [
'#type' => 'item',
'#title' => $this
->t('Attachments'),
'#markup' => \Drupal::service('renderer')
->render($file_links),
];
}
return $element;
}