Actions
Feature #90243
closedAdd prefix/suffix message to EmailToSender | EmailToReceiver
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2020-01-29
Due date:
% Done:
0%
Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:
Description
It would be nice to have a message field in the EmailToSender and EmailToReceiver finishers.
The form values are enought for the EmailToReceiver mail. But in the mail to the sender its required to write some informations before and after the form values.
Of corse i can set an individual value ({@format}-form1.html -> Finishers/Email/Html-form1.html and Finishers/Email/Plaintext-form1.html) for the template option in this finishers. But so i must create an individual temlate for each form.
It would be also nice to have, if the values can be used in this message fields
Eg.
Hello {lastname},
we have received your request and get in contact with you as soon as possible.
###FIELDDATA###
Best regards
COMPANY
Wish
finishers: 10: options: subject: 'Contactform' recipientAddress: '{recipient-address}' recipientName: '' senderAddress: '{sender-address}' senderName: '{sender-name}' replyToAddress: '{email}' carbonCopyAddress: '' blindCarbonCopyAddress: '' format: html attachUploads: false messageBefore: "Hello {lastname},\nwe have received..." messageAfter: "Best regards\nCompany" identifier: EmailToReceiver
{namespace formvh=TYPO3\CMS\Form\ViewHelpers} <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="format-detection" content="telephone=no"> </head> <body> <f:if condition="messageBefore"> <p>{messageBefore -> f:format.nl2br()}</p> </f:if> <table width="600" cellpadding="0" cellspacing="0" border="0"> <formvh:renderAllFormValues renderable="{form.formDefinition}" as="formValue"> <tr> <td width="600" valign="top" align="left">{formvh:translateElementProperty(element: formValue.element, property: 'label')}</td> <td width="600" valign="top" align="left"> <f:if condition="{formValue.value}"> <f:then> <f:if condition="{formValue.isMultiValue}"> <f:then> <table cellspacing="0" border="0"> <f:for each="{formValue.processedValue}" as="value"> <tr> <td>{value}</td> </tr> </f:for> </table> </f:then> <f:else> <table cellspacing="0" border="0"> <tr> <td><f:format.nl2br>{formValue.processedValue}</f:format.nl2br></td> </tr> </table> </f:else> </f:if> </f:then> <f:else> - </f:else> </f:if> </td> </tr> </formvh:renderAllFormValues> </table> <f:if condition="messageAfter"> <p>{messageAfter -> f:format.nl2br()}</p> </f:if> </body> </html>
EmailFinisher.php
/** * @param FormRuntime $formRuntime * @return StandaloneView * @throws FinisherException */ protected function initializeStandaloneView(FormRuntime $formRuntime): StandaloneView { $format = ucfirst($this->parseOption('format')); $standaloneView = $this->objectManager->get(StandaloneView::class); if (isset($this->options['templatePathAndFilename'])) { $this->options['templatePathAndFilename'] = strtr($this->options['templatePathAndFilename'], [ '{@format}' => $format ]); $standaloneView->setTemplatePathAndFilename($this->options['templatePathAndFilename']); } else { if (!isset($this->options['templateName'])) { throw new FinisherException('The option "templateName" must be set for the EmailFinisher.', 1327058829); } $this->options['templateName'] = strtr($this->options['templateName'], [ '{@format}' => $format ]); $standaloneView->setTemplate($this->options['templateName']); } $standaloneView->assign('finisherVariableProvider', $this->finisherContext->getFinisherVariableProvider()); if (isset($this->options['templateRootPaths']) && is_array($this->options['templateRootPaths'])) { $standaloneView->setTemplateRootPaths($this->options['templateRootPaths']); } if (isset($this->options['partialRootPaths']) && is_array($this->options['partialRootPaths'])) { $standaloneView->setPartialRootPaths($this->options['partialRootPaths']); } if (isset($this->options['layoutRootPaths']) && is_array($this->options['layoutRootPaths'])) { $standaloneView->setLayoutRootPaths($this->options['layoutRootPaths']); } if (isset($this->options['variables'])) { $standaloneView->assignMultiple($this->options['variables']); } $standaloneView->assign('form', $formRuntime); $standaloneView->assign('messageBefore', $this->parseOption('messageBefore')); $standaloneView->assign('messageAfter', $this->parseOption('messageAfter')); $standaloneView->getRenderingContext() ->getViewHelperVariableContainer() ->addOrUpdate(RenderRenderableViewHelper::class, 'formRuntime', $formRuntime); return $standaloneView; }
Actions