I have run into a wall trying to find a solution to this problem and am hopeful someone here may have some feedback or ideas. (I'm on Drupal 8 btw)

A department in my organization wants a form with a multi-selection (checkboxes) field with 10 different options. They have text paragraphs that correspond with each option that they want to email to the user, but only if they select those options. Right now the only ways I can think of to approach this is to:

  1. create separate emails for each individual service, so they would receive as many different emails as they select services (which is not ideal because we don't want to blow up their inbox)
  2. use conditional logic on the emails based on user selection (which is not feasible because 10 options would yield 1023 different combinations)

What I'm wondering is: is there a way to have a Drupal webform pull content from a provided source and insert that into the email it sends based on what a user selects?

For example, let's say this checkboxes field lists different subject areas where a student needs assistance: math, science, art, history, geography, french. If the student selects math, science and art, I'd like the email to contain the corresponding text paragraphs for each of those subjects and none of the others. Similarly, if they select history and geography, or only french, the email would contain those respective text paragraphs. Is this possible to do somehow? Or is there another way to approach this? I would be very grateful for any insight or help!

I see the webform module has handlers (action, debug, remote post, and settings) but I'm not entirely sure if these can do what I'm trying to do, and if so, how they work?

I did find this post: How to conditionally change email content from Webform submissions which asks a very similar question, though I don't understand the provided suggestions.

  • I tagged the other question with "7" because it is related to a prior version of Drupal. I tagged this question "9", which, I assume, is the target version. If this question is about 7, then this will be a duplicate of the other question. Did you consider a "Computed Twig" field for this?
    – mona lisa
    Commented Sep 21, 2022 at 18:19
  • @cilefen Hi, sorry I should have specified. I am currently on Drupal 8. I wasn't aware of Computed Twig fields to be honest. I see they are a different field type on their own. How would I configure/use that type of field to customize the email output? Commented Sep 21, 2022 at 18:47


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.