Feature #90243

EmailToSender | EmailToReceiver

Added by Reindl Bernd 27 days ago. Updated 27 days ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2020-01-29
Due date:
% Done:

0%

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;
    }

History

#1 Updated by Reindl Bernd 27 days ago

Plaintext template:

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:formvh="http://typo3.org/ns/TYPO3/CMS/Form/ViewHelpers" data-namespace-typo3-fluid="true">
<f:if condition="messageBefore">{messageBefore -> f:format.raw()}

</f:if><formvh:renderAllFormValues renderable="{form.formDefinition}" as="formValue"><f:spaceless>
    <f:if condition="{formValue.isMultiValue}">
        <f:then>
<formvh:translateElementProperty element="{formValue.element}" property="label" />:
    <f:for each="{formValue.processedValue}" as="singleValue">- {singleValue}
    </f:for>
        </f:then>
        <f:else>
<formvh:translateElementProperty element="{formValue.element}" property="label" />: <f:if condition="{formValue.processedValue}"><f:then>{formValue.processedValue -> f:format.raw()}</f:then><f:else>-</f:else></f:if>
</f:else>
    </f:if>
</f:spaceless>
</formvh:renderAllFormValues><f:if condition="messageAfter">

{messageAfter -> f:format.raw()}</f:if>
</html>

Also available in: Atom PDF