I wanted to get the form id of particular forms to customize those forms. I dont want to use form alter hook to obtain the form id every time. I wanted a simple way to acquire the form_id of the forms. Like a simple PHP snippet that can be executed in Devel execute PHP to obtain the form ID. or is there any other way to do it?

3 Answers 3


I don't think it's possible to do this without something (either your custom module or another module) implementing hook_form_alter(). The Devel execute PHP form is in a block which has no real idea what forms are available on the page.

I'm sure you know the way to get the form ID but just in case this will print it at the top of every form:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if (user_access('whatever permission you want')) {
    $form['mymodule_form_id'] = array(
      '#markup' => '<p>Form ID: ' . $form_id . '</p>',
      '#weight' => -10000

If you really don't want to do this, though, why not just use developer tools/firebug to inspect the form element on the page itself...you'll find the form id in one of the hidden input fields.


I know this is outdated but I'll post it for googlers who end up here - I wanted to improve upon the answer previously posted. In your custom module implement hook_form_alter(), and using the Devel module, use the dpm() function.

For example:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {

Save, clear cache, and then load the desired form in your drupal website. You should see a green system message that displays the form ID, for example, article_node_form.

Make sure you have the devel module enabled and sufficient permissions to use the devel module.


Use Get Form ID module to easily find out form id of any form in Drupal: http://drupal.org/project/get_form_id

  • Normally, answers with little more than a link aren't considered good ones on DA. Can you expand this a little bit? Also, is this your module? Recommending your own module is fine in an answer (as long as you just don't provide a link), but we prefer that people disclose they are the module writer.
    – mpdonadio
    May 2, 2013 at 12:59

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.