Problem/Motivation
In the Drupal 7 version of this module, there is a checkbox called "Exclude empty components" when creating an email handler. In the Drupal 8 version this is no longer offered and empty components are just ignored when sending the email.
Proposed resolution
I suggest adding a checkbox called 'Show empty elements" when defining the email handler that will therefore include empty values in the email output.
A workaround can be to create a fully custom email template where you specify label + [webform-submission:values:key], but this is far from ideal.
Remaining tasks
The patch will need to be reviewed and it'll be ideal to include tests as well.
User interface changes
There is a new checkbox in the settings area when defining an email handler.
Comment | File | Size | Author |
---|---|---|---|
#20 | option_to_include_empty-2888717-20.patch | 117.51 KB | jrockowitz |
| |||
#17 | option_to_include_empty-2888717-17.patch | 116.87 KB | jrockowitz |
#11 | option_to_include_empty-2888717-11.patch | 10.66 KB | fjgarlin |
#8 | option_to_include_empty-2888717-8.patch | 10.73 KB | fjgarlin |
#5 | option_to_include_empty-2888717-5.patch | 4.75 KB | fjgarlin |
Comments
Comment #2
fjgarlin CreditAttribution: fjgarlin at Amazee Labs commentedComment #3
fjgarlin CreditAttribution: fjgarlin at Amazee Labs commentedThis patch adds the desired checkbox and displays empty values when creating the email template, so we just need to use:
[webform-submission:values]
.Comment #5
fjgarlin CreditAttribution: fjgarlin at Amazee Labs commentedUpdated patch with missing configuration.
Comment #7
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@fjgarlin The feature and patch makes sense to me.
Please include a simple test in \Drupal\webform\Tests\Handler\WebformHandlerEmailAdvancedTest that verifies empty elements are included.
Comment #8
fjgarlin CreditAttribution: fjgarlin at Amazee Labs commentedHi @jrockowitz,
I'm not very experienced with the testing procedure so it took me a while to figure out, thanks for suggesting though. I added simple test in the patch, run the tests on my D8 installation and everything went green.
New patch re-uploaded.
Comment #9
fjgarlin CreditAttribution: fjgarlin at Amazee Labs commentedComment #11
fjgarlin CreditAttribution: fjgarlin at Amazee Labs commentedPrevious patch used
git add -N new_file
and thegit diff
assumed that it was an existing file.For this one I used
git add
and thengit diff --cached
. I hope it applies this time.Comment #13
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@fjgarlin I think there are two issues here.
Some minor tweaks...
Comment #14
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI am going to work on making this feature also applicable to a previews elements.
Comment #17
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@fjgarlin I took a similar approach but went with a different variable name (exclude_empty).
Comment #20
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #22
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed that patch. Please download the latest dev release to review.
Comment #23
fjgarlin CreditAttribution: fjgarlin at Amazee Labs commentedHi @jrockowitz, that's great! Thanks for picking this up and improve. Will download and test.