I have installed CAPTCHA module. In CAPTCHA module I need to give the machine name of a form of another module called Printer, e-mail and PDF versions. How do I find the machine_name of this from.

If I could list all the machine names somewhere, I will probably figure out the machine name of that form.

2 Answers 2


It sounds like that just means the form ID. As far as finding the form ID from the interface (which i assume is what you're trying to accomplish), what you can do if you have something like Firefox with Firebug is inspect the form whose ID you're trying to get (or view the source code of the page if not). In the div element that wraps that form you will find an id like form-id-of-the-form. That will likely be the ID of the form Captcha is looking for or it may be that with underscores form_id_of_the_form.

Alternatively, you can make a custom module to get the form ID rather quickly. Just make a small module with this code in it:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  drupal_set_message('The form ID is ' . $form_id);

...and navigate to the page with the form in question.

  • 1
    Thanks, I was looking for the Form ID exactly. I took it from id="print-mail-form", converted it to print_mail_form and provided to CAPTCHA module, worked just fine. I had to test the from as anonymous user, since by default CAPTCHA is not enabled for administrator.
    – AKR
    Sep 19, 2011 at 1:40

Creating a registry of all form IDs on a site is, in general, impossible because you can create dynamic form IDs by using hook_forms. If you want to add an identical button to, say, every image in a gallery you might actually want to do that.

function example_forms($form_id, $args) {
  $forms = array();
  if (!empty($args) && is_object($args[0]) && isset($args[0]->nid) && $form_id == 'example_myform_' . $args[0]->nid) {
    $forms[$form_id]['callback'] = 'example_myform';
  return $forms;

now you can call drupal_get_form('example_myform_' . $node->nid, $node) without a problem for any node and have as many form IDs as nodes. I find this easier than putting the gallery inside a form (say, it's generated by Views...) and generating a different-named button with a button-level #submit handler.

Anyways, I am sure there are other problems making it necessary to have an arbitrary number of form IDs.

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.