Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
As mentioned here, there is a request to be able to choose a referenced entity field and from that referenced entity, choose an email field to send to.
Comment | File | Size | Author |
---|---|---|---|
#3 | interdiff-2833627-3.txt | 3.56 KB | scott_euser |
#3 | allow_referenced_emails-2833627-3.patch | 10.36 KB | scott_euser |
#2 | allow_referenced_emails-2833627-2.patch | 9.53 KB | broon |
Comments
Comment #2
broonHere's a patch to tackle this issue.
How does it work?
On the Contact Email settings form I expanded the options and added a new one "Send this email to the value of a specific field in an entity reference".
The module retrieves all entity reference fields from the contact form and checks whether or not the referenced entity type (or bundle) got any email fields set up. These "referenced" email fields are turned into options in the settings form.
Everything is pretty much in line with the recently added option to choose an email field from the contact form, just added one level of complexity. It currently works for my use case as described in #2826305: Ability to send a mail to a custom field on a contact form rather than just the sender field:
This way, the email address of the team member stays hidden which is paramount these days.
Comment #3
scott_euser CreditAttribution: scott_euser at Fat Beehive commentedLooks good, thanks for the contribution!
I've just updated it to:
- fix the phpcs issue of inline comments
- handle if the referenced entity's email field has a cardinality of more than 1
- changed the description to make it clear that the form needs both a reference field and an email field within that reference field
Comment #4
scott_euser CreditAttribution: scott_euser at Fat Beehive commentedAh and I removed your $debugs, they didn't seem to be doing anything.
Comment #5
broonAll valid points, thanks for reviewing. And the debug lines were just the ones I missed during cleaning up, thanks for spotting.
There's nothing to add from my side right now, looks like it could be committed.
Comment #7
scott_euser CreditAttribution: scott_euser at Fat Beehive commented