3

I have a reservation form for booking restaurants. All restaurants are added dynamically into the webform using Webform Views Select.

When the user selects resturant1, that restaurant should get an email of the reservation. Restaurants are nodes and, when I add them, I add an email field too, so this is in the database. But still I can't figure out how to make this work.

I know I need to use rules but I'm not really sure how to set it up.

0

2 Answers 2

2

I assume the view you are using creates an option list of key|value pairs of the form nid|Restaurant name. For this answer, I will call your select element restaurant.

  1. Install and activate the Webform node value module. This is a new module, and you will have to apply this patch. (If you are not familiar with patches have a look at Applying Patches.)

  2. Edit your webform, and under Form components create a "Hidden" webform element called send_to_email.

  3. Under E-mails add Component value: send_to_email as the to address.

  4. Under Form settings go to the bottom and open the Set Value From A Node group.

    • The Path To Node is From webform field.
    • Since the key returned is nid, set the Path Alias Prefix to node/ so the nodes can be found using node/nid as the path.
    • The Webform Source Field is restaurant (your select element).
    • If the field containing the email address of the restaurant is $node->field_email, set the Node Source Field to field_email.
    • The Webform Target Field is send_to_email.
2
  • In meanwhile i tried another approach with Entityforms but im gonna try this answer too.
    – Alex
    Commented Apr 11, 2013 at 9:32
  • This answer is amazing. Been trying to configure something like this for weeks. Commented Jun 19, 2015 at 18:02
0

As you setup the outgoing mails with the webform module, you can select another webform field value as the source for the recipient of the outgoing email.

As you have select options, the value of the field needs to be the email and the title the name of the restaurant.

1
  • The select list is being created dynamically. The email address cannot be used as a key value because keys are restricted to letters, numbers and underscores. Therefore the email address will have to be determined after the selection has been made, based on the selected key value. There are also security considerations with placing plain text email addresses in the page code.
    – Triskelion
    Commented Apr 10, 2013 at 23:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.