verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
93 stars 69 forks source link

Invalid HTML in Email notification #1806

Closed Megafry closed 2 months ago

Megafry commented 2 months ago

Describe the bug

The variables All Form Fields or All Visible Fields are placed in a p-tag, but the field templates already come with their own p-tags. Repeat/Group fields generate tables.

Therefore the HTML generated is not valid.

<p>
  <p>
    <strong>Field 1</strong><br>18-24
  </p>
  <div style="margin: 1em 0;">
    <strong>Field 2</strong>
      <table style="width: 100%; margin: 1em 0; border-collapse: collapse;">
        ...
      </table>
  </div>
</p>

This creates issues in Outlook and other mail clients.

Fix: The best solution would be to remove the p tag that wraps the variable. But only for All Form Fields, All Non Empty Fields and All Visible Fields.

Steps to reproduce

  1. Create a new form
  2. Add a group and text field
  3. Create a new notification with the variable All Form Fields
  4. Generate the email preview
  5. Inspect the html

Form settings

Craft CMS version

4.8.6

Plugin version

2.1.9

Multi-site?

No

Additional context

No response

engram-design commented 2 months ago

That's a tricky one indeed, as we use the WYSIWYG editor to insert those variables, which will create paragraph tags around any elements, whether it be text, links or these variable tags.

Fixed for the next release. To get this early, run composer require verbb/formie:"dev-craft-4 as 2.1.9".

engram-design commented 2 months ago

Fixed in 2.1.10