I would like to insert a contact form into a block. What's the best way to do it?
I'm using 5.0 RC.

Comments

pwolanin’s picture

Here's a snippet in the handbook that shows how I did it for 4.7 by re-using the functionality already present in the contact module: http://drupal.org/node/73973

If you want to do the same in 5.x, you'll have to adapt the code a little due to the changes in the Forms API

---
Work: BioRAFT

pwolanin’s picture

If you want help working it out, the forum is a better place- then we can post the final solution back to the handbook.

take a look at the Forms API docs:

http://api.drupal.org/api/HEAD/file/forms_api.html

http://api.drupal.org/api/HEAD/file/forms_api_reference.html

with the caveat that these may not be totally updated for 5.x yet.

So, see also:

http://drupal.org/node/64279#drupal-get-form

Basically, the function needs to be refactored into a form-building function due to the changes in drupal_get_from, and note also this bit:

the use of $form['#base'] is also important to note. It's a lot like the little-used but helpful $callback parameter that was used in the 4.7.x version of drupal_get_form().

So, since the code I posted used the $callback parameter, this information needs to be moved into $form['#base']. Also, I'm not sure if there have been any relevant changes to the contact module.

---
Work: BioRAFT

erinc’s picture

Sorry for the comment I left on the handbook and thank you very much for your help. It was too much work to convert the snippet.
I ended up copy/pasting the html output.

www.erinch.com