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.
Comments
Comment #2
fjgarlin commentedComment #3
fjgarlin 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 commentedUpdated patch with missing configuration.
Comment #7
jrockowitz 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 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 commentedComment #11
fjgarlin commentedPrevious patch used
git add -N new_fileand thegit diffassumed that it was an existing file.For this one I used
git addand thengit diff --cached. I hope it applies this time.Comment #13
jrockowitz commented@fjgarlin I think there are two issues here.
Some minor tweaks...
Comment #14
jrockowitz commentedI am going to work on making this feature also applicable to a previews elements.
Comment #17
jrockowitz commented@fjgarlin I took a similar approach but went with a different variable name (exclude_empty).
Comment #20
jrockowitz commentedComment #22
jrockowitz commentedI committed that patch. Please download the latest dev release to review.
Comment #23
fjgarlin commentedHi @jrockowitz, that's great! Thanks for picking this up and improve. Will download and test.