1

I'm creating a website that has a contact form on two different pages.

I am using the Pixel & Tonic ContactForm plugin and currently have a working contact form on one page - This one requires the user to provide their name, email, telephone, company name and message.

On the other page, the contact form is different as the user needs to select which department they would like their message to be sent to. For example:

  <div class="select-wrapper">
   <select name="department" id="department">
    <option value="">- Please Select -</option>
      <option value="one">Business One</option>
      <option value="two">Business Two</option>
      <option value="three">Business Three</option>
      <option value="four">Business Four</option>
   </select>
 </div>

In the README document for this plugin, I can see that it is possible to programatically add email recipients by adding a hidden input field named “toEmail” and changing the craft/config/contactform.php config file

But, is it possible to do this when there is another contact form on the site? If so, what do I need to add to the department dropdown code?

1 Answer 1

3

But, is it possible to do this when there is another contact form on the site?

Yes?

If so, what do I need to add to the department dropdown code?

The dropdown code shouldn't have anything to do with it, if I'm following you correctly.

Both forms just need to have a toEmail hidden input as specified in the docs: https://github.com/pixelandtonic/ContactForm#dynamically-adding-email-recipients-requires-craft-25

2
  • Great news! So on the dropdown feature, is it possible to have multiple different "toEmail" options, depending on which business they would like the message to go to?
    – Stak
    Commented Feb 5, 2017 at 10:49
  • @Stak you can set the toEmail value using JavaScript on change of the selected dropdown option. It's probably also possible to dynamically set/override the data from a contactForm.beforeSend event listener.
    – carlcs
    Commented May 6, 2017 at 7:04

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.