1. Create a webform that has condition to hide some page.
2. Configure it to send submission data to Email and tick "Exclude empty components".
3. Complete a submission so that page was hidden.
4. You'll see labels with empty values in your letter even though it has to be excluded.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sickness29 created an issue. See original summary.

sickness29’s picture

Status: Active » Needs review
FileSize
640 bytes

I'm attaching patch that removes not only empty components, but also components that don't show up in submission data. Not sure if it's 100% fix for that, but at least it may help someone.

JoshaHubbers’s picture

I see you excluded "pagebreak", you may also want to exclude "markup"?

sickness29’s picture

FileSize
666 bytes

I excluded only elements that can have child elements inside.

I've attached updated version of a patch. Forgot about fieldset.

Status: Needs review » Needs work

The last submitted patch, 4: empty-pages-email-2894251-4.patch, failed testing. View results

sickness29’s picture

Status: Needs work » Needs review
FileSize
2.68 KB

Fixed few issues with empty fieldsets being shown in email.

Liam Morland’s picture

It would be great to see some tests for this.

pounard’s picture

With or without tests, here is a much, much simpler solution.

Liam Morland’s picture

Thanks for the patch.

Why this change?

-    if (!empty($email['exclude_empty'])) {
+    if ($email && $email['exclude_empty']) {

It looks like these two are trying to accomplish the same thing. Why use foreach instead of implode()?

-        if (implode($data) == '') {
+          foreach ($submission->data[$cid] as $value) {
+            if ($value != '') {
Liam Morland’s picture

@#6: Instead of special handing for fieldset and pagebreak components, use properties set in hook_webform_component_info() so that custom components can be configured for the behavior they should have.

Liam Morland’s picture

Status: Needs review » Needs work
pounard’s picture

It looks like these two are trying to accomplish the same thing. Why use foreach instead of implode()?

Honestly, I don't remember, I did a quick and dirty patch to have it working on a production site. I wrote a very verbose piece of code that does probably more checks than it should be, but it did solve problems on my end.

Liam Morland’s picture