Email handler shows field set titles despite all child fields are excluded

Created on 22 October 2024, 2 months ago

Problem/Motivation

When using the Webform email handler in combination with the webform_submission:values token to display submission data, the titles of (nested) fieldsets are shown, even when all the child fields within those fieldsets are excluded from the email output.

For example, if a fieldset contains several fields, and all those fields are excluded from the email values/markup, the fieldset title is still rendered, despite having no visible children. This results in empty fieldset titles appearing in the email.

Steps to reproduce

Create a Webform with nested fieldsets like:

  • Fieldset title 1
    • Field 8
    • Field 9
  • Fieldset title 2
    • Fieldset title 2.1
      • Field 10
      • Field 11
    • Field 12
    • Field 13
  • Fieldset title 3
    • Field 14
  • ...

Add an email handler to the Webform, and configure it to:

  • exclude fields field_10 and field_11 from the email output
  • exclude empty elements

Submit the Webform with all fields filled (including fields field_10 & field_11) and check the email output.

Actual result: The 'Fieldset title 2.1' will be visible but without any children ... .

Expected result:The 'Fieldset title 2.1' is not visible because all the it's childs are excluded.

Remaining tasks

Modify the Webform email handler to ensure that fieldset titles are hidden when their children are excluded from the email values.

(Like this does work great for empty children when the option exclude empty elements is enabled (and the children are not excluded).)

πŸ› Bug report
Status

Needs work

Version

6.2

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium arno_vgh Antwerp

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @arno_vgh
  • πŸ‡§πŸ‡ͺBelgium arno_vgh Antwerp
  • πŸ‡§πŸ‡ͺBelgium arno_vgh Antwerp

    Changed the status to minor because the functionality seems to work as expected when using 'Custom body...' to construct the mail template, rather than the 'Twig template...'.

    I'll continue investigating the Twig template. If I can't find a solution, or if using the custom body option proves sufficient, I'll close this issue as the functionality is working as designed.

  • @arno_vgh opened merge request.
  • πŸ‡§πŸ‡ͺBelgium arno_vgh Antwerp

    I was wrong in my previous comment (#3), the expected result was not achieved in either way.

    Checking if the child(ren) of a container should be excluded does the trick in my case. I hope someone can reproduce this problem and that these adjustments can fix it without other impact.

  • πŸ‡§πŸ‡ͺBelgium arno_vgh Antwerp
  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY
Production build 0.71.5 2024