Brecherchef
Brecherchef

Reputation: 397

Typo3: Edit the E-Mail template used by the form plugin

currently I'm working on a contact form with the basic form plugin in Typo3. I got it all set up and it works fine and as expected. The only problem I have is that the email I receive looks quite bad. My form has 10 different inputs and it just return the field in some sort of list.

the output looks like this:

male
Test     
123  
test@test,de
1

While it should look something like this:

Gender: male
Name: Test   
Age: 123     
E-Mail: test@test,de
Agreed to TOS: yes

I've tried to google for a solution to this issue since I figured it can't be that hard to create a template for this but up to this point I haven't found anything that worked for me.

I've tried this solution right here and read through the github example provided but I don't know how to apply the solution to my project. I've implemented this code to my .yaml file:

templateName: 'template.html'
  templateRootPath:
    20: 'EXT:extension/Resources/Private/Forms/Templates/'

But as soon as I try to submit the form I get a bunch of errors. I also don't know what to write in the template file itself, I've tried to just copy what's provided in the github but somehow my code won't even find my template file.

Does anyone know a solution to this problem?

Upvotes: 0

Views: 1757

Answers (1)

sebkln
sebkln

Reputation: 1375

In YAML, indentation is used to indicate nesting (the structure of your configuration). Therefore, you'll need to make sure every setting is indented right.

templateName and templateRootPaths are both equal options of the email finisher in EXT:form:

finishers:
  -
    identifier: EmailToSender
    options:
      subject: 'Your message'
      recipientAddress: '{email}'
      recipientName: '{lastname}'
      senderAddress: [email protected]
      senderName: 'Your Company name'
      replyToAddress: ''
      carbonCopyAddress: ''
      blindCarbonCopyAddress: ''
      format: html
      attachUploads: true
      # The following part enables us to use the customized template:
      templateName: '{@format}.html'
      templateRootPaths:
        20: 'EXT:form_examples/Resources/Private/Forms/CustomHtmlMailExample/Sender/'

As you already figured out yourself, form labels will be rendered in the default email template of TYPO3's Form framework. Labels and form values will be rendered in a simple HTML table, if labels were set in the form definition.

Upvotes: 2

Related Questions