-- Drupal and Web Development

Notice: this post was last updated 5 years 8 weeks ago so it might be outdated. Please be cautious before implementing any of suggestions herein.

Using prepopulate on Drupal 7's contact form

Say I have several categories in my Drupal contact form, and I'd like to create a link to the contact form, but with one of those categories preselected, and, while I'm at, prepopulate the subject and message fields, here's how I go about it.

(1) install and enable the prepopulate module.
(2) Figure out which category (recipient) you want to preselect by finding its ID on the page
(3) Say your message is "this is my message" and your subject is "I'd like some more info & pricing please": pass those two strings in php's urlencode() function.
(4) Put everything in the following format:



If our cid (category ID) is 14, this would give us the following path

Note that if you want several lines on your message, a newline is encoded as %0A (for some reason I can't get urlencode() to generate this for me)

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.